I have a python 3.6 anaconda environment.
I tried using use_python and giving it the path to the environment which did not work.
I also tried using use_condaenv which did not work, once I run py_config I get the following output:
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, Feb 7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.0python versions found:
/usr/bin/python
/anaconda3/envs/my-r-env/bin/python
/anaconda3/envs/py27/bin/python
/anaconda3/envs/py36/bin/python
I was able to get things working by creating an .Rprofile file (either in your home dir or in the project dir) with the following:
Sys.setenv(RETICULATE_PYTHON = '/anaconda3/bin/python3')
or whichever python executable you want to use, as mentioned in #216.
did not seem to work.
I also have numpy installed in my environment
Is your output of reticulate::py_config() the same when you set the RETICULATE_PYTHON env. var?
Mine changes from what you posted to:
python: /anaconda3/bin/python3
libpython: /anaconda3/lib/libpython3.7m.dylib
pythonhome: /anaconda3:/anaconda3
version: 3.7.0 (default, Jun 28 2018, 07:39:16) [Clang 4.0.1 (tags/RELEASE_401/final)]
numpy: /anaconda3/lib/python3.7/site-packages/numpy
numpy_version: 1.15.1
NOTE: Python version was forced by RETICULATE_PYTHON
And did you point to the python in the root conda env, or did you also try pointing to one of the python binaries in the envs (e.g., /anaconda3/envs/my-r-env/bin/python)?
This is what I tried as well as the output:
py_config()
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, Feb 7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.0
python versions found:
/usr/bin/python
/anaconda3/envs/my-r-env/bin/python
/anaconda3/envs/py27/bin/python
/anaconda3/envs/py36/bin/python
> Sys.setenv(RETICULATE_PYTHON = '/anaconda3/envs/py36/bin/python')
> py_config()
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, Feb 7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version: 1.8.0
python versions found:
/usr/bin/python
/anaconda3/envs/my-r-env/bin/python
/anaconda3/envs/py27/bin/python
/anaconda3/envs/py36/bin/python
>
Instead of setting that env in the console, try putting Sys.setenv(RETICULATE_PYTHON = '/anaconda3/bin/python3') in an .Rprofile file in your home dir or project dir and restart your R session.
I entered this into the r studio console.
I am sorry is did not really understand what you are recommending I do
Use your favorite text editor to create a new file with the following contents:
Sys.setenv(RETICULATE_PYTHON = '/anaconda3/bin/python3')
Save the text file (or edit an existing file if it's already there) to your home directory (e.g., /Users/cs4242/ if you are on macOS) called .Rprofile. So the full path of the file will be /Users/cs4242/.Rprofile.
You can verify the contents of this file by running the following command in a terminal window, which should return the contents of the file, as shown on the second line.:
$ cat ~/.Rprofile
Sys.setenv(RETICULATE_PYTHON = '/anaconda3/bin/python3')
Now, start a fresh instance of RStudio and check the version of Python being used by inputting the following command in a console:
py_config()
If it's picking up the .Rprofile file properly, it should now be configured to use the Python binary you specified.
hi, I created an r script in R studio and did what you told me to.
seems that its still not working.
am I supposed to add this .Rprofile file into my current project workspace. I think I am not adding it into the right place
Thanks @koverholt I ended up adding Sys.setenv(RETICULATE_PYTHON = '/anaconda3/bin/python3') into the already existing .Rprofile and it worked!!
Thanks again
Use your favorite text editor to create a new file with the following contents:
Sys.setenv(RETICULATE_PYTHON = '/anaconda3/bin/python3')Save the text file (or edit an existing file if it's already there) to your home directory (e.g.,
/Users/cs4242/if you are on macOS) called.Rprofile. So the full path of the file will be/Users/cs4242/.Rprofile.You can verify the contents of this file by running the following command in a terminal window, which should return the contents of the file, as shown on the second line.:
$ cat ~/.Rprofile Sys.setenv(RETICULATE_PYTHON = '/anaconda3/bin/python3')Now, start a fresh instance of RStudio and check the version of Python being used by inputting the following command in a console:
py_config()If it's picking up the
.Rprofilefile properly, it should now be configured to use the Python binary you specified.
Also don't forget to end the .Rprofile file with a newline character or the last line will be ignored.