Hi, I am using reticulate and a virtual environment (not conda) to run Python scripts from RStudio. However, when I try to use my own (existing) virtual environment, reticulate does not use it. If I run my scripts, the installed modules (e.g., py_install("pandas", "mmstat4.hu.data")) are not found. I believe this happens because reticulate is using r-reticulate instead of mmstat4.hu.data. How can I force reticulate to use my virtual environment? Thanks Sigbert > library("reticulate") > py_config() python: /home/sk/.virtualenvs/r-reticulate/bin/python libpython: /usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so pythonhome: /home/sk/.virtualenvs/r-reticulate:/home/sk/.virtualenvs/r-reticulate version: 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] numpy: /home/sk/.virtualenvs/r-reticulate/lib/python3.10/site-packages/numpy numpy_version: 2.0.0 > use_virtualenv("mmstat4.hu.data", required = TRUE) > py_config() python: /home/sk/.virtualenvs/r-reticulate/bin/python libpython: /usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so pythonhome: /home/sk/.virtualenvs/r-reticulate:/home/sk/.virtualenvs/r-reticulate version: 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] numpy: /home/sk/.virtualenvs/r-reticulate/lib/python3.10/site-packages/numpy numpy_version: 2.0.0 -- https://hu.berlin/sk https://hu.berlin/mmstat
Have you tried https://rstudio.github.io/reticulate/ ? Generally speaking, complex nonstandard package specific questions such as yours rarely get a reply here -- there are 20,000+ packages (and counting) after all! As reticulate was created by and integrated with RStudio/Posit, I would think their site and help resources might be a better venue. Of course, if you don't use RStudio, you may have no joy there either. Cheers, Bert On Sun, Jul 14, 2024 at 10:56?PM Sigbert Klinke <sigbert at wiwi.hu-berlin.de> wrote:> > Hi, > > I am using reticulate and a virtual environment (not conda) to run > Python scripts from RStudio. However, when I try to use my own > (existing) virtual environment, reticulate does not use it. If I run my > scripts, the installed modules (e.g., py_install("pandas", > "mmstat4.hu.data")) are not found. I believe this happens because > reticulate is using r-reticulate instead of mmstat4.hu.data. How can I > force reticulate to use my virtual environment? > > Thanks Sigbert > > > library("reticulate") > > > py_config() > > python: /home/sk/.virtualenvs/r-reticulate/bin/python > > libpython: > /usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so > > pythonhome: > /home/sk/.virtualenvs/r-reticulate:/home/sk/.virtualenvs/r-reticulate > > version: 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] > > numpy: > /home/sk/.virtualenvs/r-reticulate/lib/python3.10/site-packages/numpy > > numpy_version: 2.0.0 > > > use_virtualenv("mmstat4.hu.data", required = TRUE) > > > py_config() > > python: /home/sk/.virtualenvs/r-reticulate/bin/python > > libpython: > /usr/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.so > > pythonhome: > /home/sk/.virtualenvs/r-reticulate:/home/sk/.virtualenvs/r-reticulate > > version: 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] > > numpy: > /home/sk/.virtualenvs/r-reticulate/lib/python3.10/site-packages/numpy > > numpy_version: 2.0.0 > > -- > https://hu.berlin/sk > https://hu.berlin/mmstat > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
? Mon, 15 Jul 2024 07:56:17 +0200 Sigbert Klinke <sigbert at wiwi.hu-berlin.de> ?????:> > py_config()> > use_virtualenv("mmstat4.hu.data", required = TRUE)Does it help _not_ to call py_config() before use_virtualenv()? help(py_config) says that it forces the initialization of Python. When you later try to ask for a different virtual environment, no conflict is detected because normalizePath('/home/sk/.virtualenvs/r-reticulate/bin/python') is identical to normalizePath('/home/sk/.virtualenvs/mmstat4.hu.data/bin/python'): they must be both symlinks to /usr/bin/python3, so reticulate is likely thinking that it's the same Python. Thus Python is not initialised again, but you also don't see an error. -- Best regards, Ivan
Seemingly Similar Threads
- reticulate + virtual environments
- Converting non-32-bit integers from python to R to use bit64: reticulate
- State-of-the-art NLP models from R
- Converting non-32-bit integers from python to R to use bit64: reticulate
- Users appears as SID instead of their own name.