'Configuring reticulate to use conda environment
I'm trying to get R's reticulate package to detect the Python interpreter in one of my conda-environments. Following several posts and questions, I've attempted to
set the
RETICULATE_PYTHONenvironment variable in .Rprofile (both in user as well as project directory)set
RETICULATE_PYTHONin a.Renvironfileuse the provided helper functions
use_python()anduse_condaenv(),
all in vain. On start-up, the environment variable is correctly configured:
Sys.getenv("RETICULATE_PYTHON")
[1] "C:\\Users\\Othman\\anaconda3\\envs\\data_science\\python.exe"
but as soon as I run py_config(), it automatically sets it to the global (base) Python install:
r$> py_config()
python: C:/Users/Othman/anaconda3/python.exe
libpython: C:/Users/Othman/anaconda3/python39.dll
pythonhome: C:/Users/Othman/anaconda3
version: 3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/Othman/anaconda3/Lib/site-packages/numpy
numpy_version: 1.20.3
NOTE: Python version was forced by RETICULATE_PYTHON
r$> Sys.getenv("RETICULATE_PYTHON")
[1] "C:\\Users\\Othman\\anaconda3\\python.exe"
Any idea what could be causing this?
Solution 1:[1]
Ok, so after a few frustrating hours, I finally figured out the problem. If you use the improved radian console for R (available here), which is written in Python, it forces the reticulate to use the same Python runtime. Hopefully this helps save someone who (like me) glanced over the FAQ some time and frustration.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Othman El Hammouchi |
