[R] reticulate + virtual environments

Sigbert Klinke @|gbert @end|ng |rom w|w|@hu-ber||n@de
Mon Jul 15 17:17:24 CEST 2024


Hi,

thanks, I posted in the Posit community.

Sigbert

Am 15.07.24 um 16:41 schrieb Bert Gunter:
> 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 using 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 using 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.

-- 
https://hu.berlin/sk
https://hu.berlin/mmstat



More information about the R-help mailing list