Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_python appears to have no effect #45

Closed
cb4github opened this issue Apr 12, 2017 · 5 comments
Closed

use_python appears to have no effect #45

cb4github opened this issue Apr 12, 2017 · 5 comments

Comments

@cb4github
Copy link

Please excuse my poor or incorrect usage, if any, in the following.

> library(reticulate)
> py_config()
python:         /home/<my id>/anaconda3/bin/python
libpython:      /home/<my id>/anaconda3/lib/libpython3.5m.so
pythonhome:     /home/<my id>/anaconda3:/home/<my id>/anaconda3
version:        3.5.2 |Anaconda custom (64-bit)| (default, Oct 20 2016, 03:10:33)  [GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]
numpy:          /home/<my id>/anaconda3/lib/python3.5/site-packages/numpy
numpy_version:  1.11.2

python versions found: 
 /usr/bin/python
 /usr/bin/python3
 /home/<my id>/anaconda3/bin/python

Attempting to change python version:

> use_python("/usr/bin/python", required = T)

Observe - no apparent change:

> py_config()
python:         /home/<my id>/anaconda3/bin/python
libpython:      /home/<my id>/anaconda3/lib/libpython3.5m.so
pythonhome:     /home/<my id>/anaconda3:/home/<my id>/anaconda3
version:        3.5.2 |Anaconda custom (64-bit)| (default, Oct 20 2016, 03:10:33)  [GCC 4.8.2 20140120 (Red Hat 4.8.2-15)]
numpy:          /home/<my id>/anaconda3/lib/python3.5/site-packages/numpy
numpy_version:  1.11.2

python versions found: 
 /usr/bin/python
 /usr/bin/python3
 /home/<my id>/anaconda3/bin/python
> R.version
               _                           
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          3                           
minor          3.3                         
year           2017                        
month          03                          
day            06                          
svn rev        72310                       
language       R                           
version.string R version 3.3.3 (2017-03-06)
nickname       Another Canoe               
> 

Shouldn't the result of use_python be reflected in the result of py_config()?

Please let me know if you need more info, thanks.

Best,
CB

@cb4github
Copy link
Author

> packageVersion("reticulate")
[1] ‘0.7’
> 

@jjallaire
Copy link
Member

You can only load one Python interpreter per R session (it can't really be cleanly unloaded without messy side effects that cause crashes down the road) so the use_python call only applies before you actually initialize the interpreter.

@bryanhanson
Copy link

bryanhanson commented Mar 26, 2018

To any newbies out there (like me), this means do:

library("reticulate")
use_python("/usr/bin/python", required = T)

Before anything else. Check with

py_config()

@battmanux
Copy link

I actually do:

reticulate::use_python("python3")
library(reticulate)

@flying-sheep
Copy link
Contributor

That doesn’t work, you should do

reticulate::use_python(Sys.which('python3'), required = TRUE)

And there’s no difference if you do it before library(reticulate) or after, as long as it’s before you try to run any other stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants