reticulate: python 2 works, python 3 does not

211 Views Asked by At

I am trying to get rgee properly installed for which python is a requirement. I have both an old version of python (2.7) and a new version (3.10) installed on my Mac running Big Sur OS. Installed via homebrew.

I can set the location correctly for python in reticulate using

use_python(Sys.which("python3"))

But when I try something simple like

np <- reticulate::import("numpy", convert = FALSE)

I get the error

Error in py_module_import(module, convert = convert) : 
  ModuleNotFoundError: No module named 'numpy'

Running the same code when using python 2.7 (after restarting r session etc.)

use_python(Sys.which("python"))

works, with warnings of EOL

Warning message:
In py_initialize(config$python, config$libpython, config$pythonhome,  :
  Python 2 reached EOL on January 1, 2020. Python 2 compatability be removed in an upcoming reticulate release.

How can I use the up-to-date version of python and still have reticulate running properly?

0

There are 0 best solutions below