How to make Anaconda packages discover-able by RMarkdown script in RStudio IDE?

I have Python + Data-Science packages installed (it's a Windows 7 machine) using Anaconda manager. These libraries are accessible from inside Anaconda Jupyter Notebook (can be launched from Windows CMD prompt in Anaconda old-version; in the latest version, there is a Navigator GUI from which Notebook is to be launched).

But when writing a R Markdown script (which uses R as well as Python) in my RStudio IDE, I'm not able to get the Rmd script find the path to Python (Anaconda specific) packages. How do I resolve this - should I make changes to .libPath?

.libPaths()
[1] "C:/Users/Username/Documents/R/win-library/3.4"
[2] "C:/Program Files/R/R-3.4.0/library"

Thank You.

1 Like

I suspect this is an issue with your Anaconda installation -- I can reproduce the same issue on my Windows machine with a fresh install of Anaconda Python. In my case, reinstalling numpy from the Anaconda Python console seems to fix it. Try running the following:

pip uninstall numpy
pip install numpy

This fixed the issue for me; hopefully it does the same for you!

1 Like

I can't be certain about Windows but in unix environment, you may specify or prepend anaconda python over system python (/usr/bin/python) to PATH in ~/.Rprofile file.

PATH="/usr/local/anaconda/bin:${PATH}"

Similarly you can prepend LD_LIBRARY_PATH in ~/.Rprofile if you have library files stored at non-standard locations.

1 Like