Saturday, 1 December 2018

using python virtual env in R

I am using 'rPython' package for calling python within R but I am unable to make R refer to my python's virtual environment.

In R, I have tried using

system('. /home/username/Documents/myenv/env/bin/activate')

but after running the above my python library path does not change (which I check via python.exec(print sys.path)). When I run

python.exec('import nltk')

I am thrown the error:

Error in python.exec("import nltk") : No module named nltk

although it is there in my virtual env.

I am using R 3.0.2, Python 2.7.4 on Ubuntu 13.04.

Also, I know I can change the python library path from within R by using

python.exec("sys.path='\your\path'")

but I don't want this to be entered manually over and over again whenever a new python package is installed.

Thanks in advance!



from using python virtual env in R

No comments:

Post a Comment