Reputation: 21
I am trying to use reticulate in R studio. I have several python options, but when running
use_python("/opt/conda/bin/python3", required = TRUE)
conda still cannot be found using the below functions. I'm pasting my python path options below. Any suggestions?
reticulate::conda_list()
reticulate::conda_python()
reticulate::conda_version()
The above functions cannot find conda.
Error: Unable to find conda binary. Is Anaconda installed?
Using py_config()
I notice I have several python options - but when specifying these I cannot initiate python.
use_python("/opt/conda/bin/python3", required = TRUE)
use_condaenv(conda = "/opt/conda/bin/python3", required = TRUE)
python: /opt/conda/bin/python
libpython: /opt/conda/lib/libpython3.8.so
pythonhome: /opt/conda:/opt/conda
version: 3.8.5 (default, Sep 4 2020, 07:30:14) [GCC 7.3.0]
numpy: /opt/conda/lib/python3.8/site-packages/numpy
numpy_version: 1.19.5
os: /opt/conda/lib/python3.8
python versions found:
/opt/conda/bin/python
/usr/bin/python3
/opt/conda/bin/python3
/usr/bin/python
/usr/local/bin/python
Upvotes: 1
Views: 1626
Reputation: 7151
The reason your code doesn't work lies in the wrong specification.
For use_python
, the path must point to the python executable of the conda environment, which looks like /opt/conda/envs/<env_name>/bin/python
. Important is that it contains the folder envs
.
For use_condaenv
, the documentation specifies about its arguments:
condaenv
The name of the Conda environment to use.
conda
The path to a conda executable. By default, reticulate will check the PATH, as well as other standard locations for Anaconda installations.
So for condaenv, you specify the name of your conda environment, e.g. "reticulate".
For conda, you specify the path of the conda executable, which you find easily by opening a terminal and typing which conda
. This gives me e.g. miniforge3/condabin/conda
(for M1 apple silicon).
In your case, it would probably look like:
use_condaenv(conda = "/opt/conda/bin/conda", condaenv = "<env_name>")
Upvotes: 1