Reputation: 83
When I was trying to import modules like "pymc3" or "theano", the rPython or PythoninR are not able to locate these modules even though I have already installed them. I am using Ubuntu 16.04, R 3.4.2, and python 3.5.2
It seems like these two packages fail to locate a certain folder, but it doesn't work after I append the path into sys.path, which contains all the packages I need, by using this command:
pyExec("sys.path.append('/home/lijiakai/.local/lib/python3.5/site-packages')")
Result also seems like good:
pyExec('import sys; print(sys.path)')
['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages', '.', '/home/lijiakai/.local/lib/python3.5/site-packages']
I imported the packages:
pyExec('import pymc3')
Then received the following errors:
Traceback (most recent call last): File "<string>", line 1, in
<module> **ImportError** : No module named 'pymc3' Error in
pyExec("import pymc3") : An error has occured while executing
Python code. See traceback above.
Totally got me crazy ... really appreciate if anyone can help me out here. Thanks
Upvotes: 0
Views: 526
Reputation: 6813
If you use anaconda, you might want to turn to turn to the package reticulate
, where you can specify the python version to use.
# install.packages("reticulate")
library(reticulate)
use_python("/anaconda/bin/python")
However, from my experience this is slower.
Otherwise, if you use 'standard' Python, you can start by removing rPython
:
remove.packages("rPython")
And then re-install it specifying the version:
install.packages("rPython", configure.vars= "RPYTHON_PYTHON_VERSION=3.5")
This should then use Python_3.5 on your machine, see here for more details.
You can test, if it was successful by using:
library(rPython)
python.exec(c("import sys", "\n", "print(sys.version)"))
Upvotes: 1