Reputation: 151
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_PYTHON
environment variable in .Rprofile (both in user as well as project directory)
set RETICULATE_PYTHON
in a .Renviron
file
use the provided helper functions use_python()
and use_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?
Upvotes: 2
Views: 1616
Reputation: 151
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.
Upvotes: 3