I just did a clean install of OSX and completely wiped everything. From there, I reinstalled Homebrew, installed Python 3, then R and RStudio with the reticulate package. I am still unable to get the python version in use to switch from the default OSX installed Python to use Python 3 instead. After opening up a brand new R Markdown file, I ran the following:
library(reticulate)
use_python("/usr/local/bin/python3", required = T)
py_config()
with these results:
python: /usr/bin/python
libpython: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome: /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version: 2.7.10 (default, Oct 6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.1
python versions found:
/usr/local/bin/python3
/usr/bin/python
Can anyone help?
reticulate will always prefer a version of Python that includes NumPy to one that doesn't. Does the version at /usr/local/bin/python3 have NumPy?
Yup. I forgot to mention that, sorry!
@jjallaire , that means if we want to use use_python or other function to specify python path or virtual environment, we must install numpy to that directory first? Otherwise it won't work?
Yes, NumPy is always preferred (without that we can't convert matrices nor data frames between Python and R).
Dear all,
I try reticulate today and feel very frustrated.
I follow the vignettes of Python Version Configuration but both functions use_python and use_virtualenv do not work as expected.
Finally, I find this issue and make thing works.
Is it possible to raise an error if use_python and use_virtualenv does not find numpy?
Then users will quickly know why use_python and use_virtualenv does not work and correct it accordingly.
This is just my two cents.
You likely want reticulate::use_python("/path/to/python", required = TRUE).
In my case, I was able to use_virtualenv without numpy installed. Output of py_config():
python: /home/xxx/pylift/bin/python
libpython: /home/xxx/opt/python-3.6.2/lib/libpython3.6m.so
pythonhome: /home/xxx/opt/python-3.6.2:/home/xxx/opt/python-3.6.2
virtualenv: /home/xxx/pylift/bin/activate_this.py
version: 3.6.2 (default, Apr 2 2019, 11:53:38) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
numpy: [NOT FOUND]
In order to get the above to work, I had to:
--enable-shared (as mentioned in the docs)Sys.setenv(LD_LIBRARY_PATH = "<PATH_TO_PYTHON_INSTALL>/lib") so that R can find the shared libraries (otherwise error is: "error while loading shared libraries")@wush978 Mine worked well on a Mac by adding:
RETICULATE_PYTHON="/usr/local/bin/python3"
to my .Renviron file. As soon as you restart R, it will find the correct version (I'm assuming you're using Python3).
I don't think this is worth a new issue, but will create one if you prefer.
Does reticulate require name-spacing? I'm brand new and these instructions failed:
` ` `{R}
library(reticulate)
use_python("/usr/bin/python3")
` ` `
Error in use_python("/usr/bin/python3") :
could not find function "use_python"
But this (idea taken from above), worked:
` ` `{R}
library(reticulate)
reticulate::use_python("/usr/bin/python3")
` ` `
If name-spacing is required, could the documentation be updated?
Most helpful comment
Dear all,
I try
reticulatetoday and feel very frustrated.I follow the vignettes of
Python Version Configurationbut both functionsuse_pythonanduse_virtualenvdo not work as expected.Finally, I find this issue and make thing works.
Is it possible to raise an error if
use_pythonanduse_virtualenvdoes not find numpy?Then users will quickly know why
use_pythonanduse_virtualenvdoes not work and correct it accordingly.This is just my two cents.