I am trying to use the reticulate package in a Rmd file. I first created a setup chunk as follows:
library(reticulate)
use_virtualenv("r-reticulate")
use_python("C:\\Python27")
Then I import pandas
:
#importing libraries
import pandas
ImportError: No module named pandas
Detailed traceback:
File "<string>", line 1, in <module>
I have checked that pandas is already installed from the python command line. Why am I getting an import error here?
install the package in R using the py_install()
library(reticulate)
py_install("pandas")
refer this -> https://rstudio.github.io/reticulate/articles/python_packages.html
It appears pandas
is not installed in your virtualenv. It may be on your machine, but your virtualenv isolates your application from the rest of your machine.
While your virtualenv is active:
pip install pandas
Now pandas
should be available to you within this env
. Later you can generate a requirements.txt
file that makes dependency management much easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With