I am struggling with reticulate
. All the time I try to run some python
code in a python script, I get the following error.
I have tried everything! Latest Rstudio, R, reticulate, Rcpp, Python.... nothing works. I really don't know what I am doing wrong.
Here is some additional information.
> library(reticulate)
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Pop!_OS 21.10
Matrix products: default
BLAS/LAPACK: /opt/OpenBLAS/lib/libopenblas_haswellp-r0.3.18.so
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reticulate_1.24
loaded via a namespace (and not attached):
[1] compiler_4.1.3 Matrix_1.4-0 tools_4.1.3 Rcpp_1.0.8.3 grid_4.1.3 jsonlite_1.8.0
[7] png_0.1-7 lattice_0.20-45
>
> py_discover_config()
python: /usr/bin/python3
libpython: /usr/lib/python3.9/config-3.9-x86_64-linux-gnu/libpython3.9.so
pythonhome: //usr://usr
version: 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
numpy: /home/ahmed/.local/lib/python3.9/site-packages/numpy
numpy_version: 1.22.3
python versions found:
/usr/bin/python3
/home/ahmed/.virtualenvs/r-test/bin/python
/home/ahmed/virtualReph/bin/python
I have also tried to run reticulate directly from R (and not RStudio), and that's what I get:
> library(reticulate)
> Sys.which("python3")
python3
"/usr/bin/python3"
> use_python("/usr/bin/python3")
> os <- import("os")
*** caught segfault ***
address 0x90, cause 'memory not mapped'
Traceback:
1: py_initialize(config$python, config$libpython, config$pythonhome, config$virtualenv_activate, config$version >= "3.0", interactive(), numpy_load_error)
2: (function() { Sys.setenv(PYTHONPATH = newpythonpath) on.exit(Sys.setenv(PYTHONPATH = oldpythonpath), add = TRUE) py_initialize(config$python, config$libpython, config$pythonhome, config$virtualenv_activate, config$version >= "3.0", interactive(), numpy_load_error)})()
3: doTryCatch(return(expr), name, parentenv, handler)
4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
5: tryCatchList(expr, classes, parentenv, handlers)
6: tryCatch({ oldpythonpath <- Sys.getenv("PYTHONPATH") newpythonpath <- Sys.getenv("RETICULATE_PYTHONPATH", unset = paste(config$pythonpath, system.file("python", package = "reticulate"), sep = .Platform$path.sep)) local({ Sys.setenv(PYTHONPATH = newpythonpath) on.exit(Sys.setenv(PYTHONPATH = oldpythonpath), add = TRUE) py_initialize(config$python, config$libpython, config$pythonhome, config$virtualenv_activate, config$version >= "3.0", interactive(), numpy_load_error) })}, error = function(e) { Sys.setenv(PATH = oldpath) if (is.na(curr_session_env)) { Sys.unsetenv("R_SESSION_INITIALIZED") } else { Sys.setenv(R_SESSION_INITIALIZED = curr_session_env) } stop(e)})
7: initialize_python(required_module, use_environment)
8: ensure_python_initialized(required_module = module)
9: import("os")
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: