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

Change Python Environment when using Anaconda #119

Closed
eisioriginal opened this issue May 23, 2017 · 8 comments
Closed

Change Python Environment when using Anaconda #119

eisioriginal opened this issue May 23, 2017 · 8 comments

Comments

@eisioriginal
Copy link

The library installs an Anaconda environment which must be actively set when using the package:

#set anaconda to tensor flow environment
reticulate::use_condaenv("r-tensorflow")

This can be done via reticulate but isn't executed via the library. In windows this prevents the library from working if r-tensorflow is not the standard environment for Python.

Thank you very much for the great package!

Andreas

@jjallaire
Copy link
Member

That conda env should be found when you go to use tensorflow unless you've got other things going on that cause another python environment to be found first. You can see here that the conda envs are given first priority after any explicitly requested environments (via environment variable or use_ directive): https://github.com/rstudio/reticulate/blob/master/R/config.R#L95-L107

What is the output of tf_config() (that will show other versions being scanned).

@jjallaire
Copy link
Member

jjallaire commented May 23, 2017 via email

@eisioriginal
Copy link
Author

eisioriginal commented May 29, 2017

Yes, I agree, but if you are on Ubuntu it uses many libraries (sssd etc.) which require Python. In almost ever installation the system python has larger priority there. So one must actively set the Python environment beforehand. On windows it is a bit easier but if another Python was used prior to Anaconda one must set the environment actively as well. I guess adding something like:

library(reticulate)
use_condaenv(condaenv = "deeplearning_R", conda = "/opt/anaconda3/bin/conda")

to the documentation would be very helpful for the users. After that the output of py_config() looks just fine:

python: /opt/anaconda3/envs/deeplearning_R/bin/python
libpython: /opt/anaconda3/envs/deeplearning_R/lib/libpython3.5m.so
pythonhome: /opt/anaconda3/envs/deeplearning_R:/opt/anaconda3/envs/deeplearning_R
version: 3.5.3 |Continuum Analytics, Inc.| (default, Mar 6 2017, 11:58:13) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
numpy: /opt/anaconda3/envs/deeplearning_R/lib/python3.5/site-packages/numpy
numpy_version: 1.12.1

python versions found:
/opt/anaconda3/envs/deeplearning_R/bin/python
/usr/bin/python
/usr/bin/python3

@jjallaire
Copy link
Member

Okay, added an additional note to the docs here: rstudio/reticulate@3209d85

@aidamian
Copy link

aidamian commented Jul 17, 2017

Hi there !
I have the following issue: although I use "use_condaenv" it seems my R still uses the root environment. This is easily self-explained by the following commands/outputs:
conda_list()
name python
1 r-tensorflow C:\Users\Andrei\Documents\.conda\envs\r-tensorflow\python.exe

use_condaenv("r-tensorflow")
tf_config()
Installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
C:\Program Files\Anaconda3\python.exe
C:\Program Files\Anaconda3\python.exe

You can install TensorFlow using the install_tensorflow() function.

@jjallaire
Copy link
Member

This might happen for a number of reasons:

  1. The installation of TensorFlow into the r-tensorflow conda env failed for some reason after the environment was created.

  2. There is a mismatch in architecture between your R session and the Anaconda architecture (e.g. 64-bit R with 32-bit Anaconda or 32-bit R with 64-bit Anaconda)

  3. Anaconda is having trouble loading within your R session (we've seen this happen with conflicting versions of MKL when running Anaconda under Microsoft R Open)

@jjallaire jjallaire reopened this Jul 18, 2017
@aidamian
Copy link

Found a workaround and the actual culprit: MS Visual Studio 2017.

So basically initially I installed MS VS 2017 that included Anaconda3 4.3 and I got the previous explained behavior.

I uninstalled the MS VS installed Conda and I re-installed with normal 4.4 installation. After this everything worked just peachy. Obviously it is a bug within the MS VS 2017 environment/installation.

So I recommend anyone who uses MS VS 2017 to install Anaconda3 separately and there will be no trouble !

@jjallaire
Copy link
Member

Okay, thanks for letting us know!

FWIW I just installed Visual Studio 2017 w/ Andaconda 3 4.3 and things did work as expected, so there might be some additional local configuration issues that led your environment to not work (hard to say of course as there are so many variables in play!)

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

3 participants