reticulate: python 2 works, python 3 does not

Issue

This Content is from Stack Overflow. Question asked by Nebulloyd

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?



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?