I want to execute a Python script in R. I've installed reticulate and tested that a Python version has correctly initialized in my R session.
py_config()
returns the following
python: C:/Users/username/AppData/Local/r-miniconda/envs/r-reticulate/python.exe
libpython: C:/Users/username/AppData/Local/r-miniconda/envs/r-reticulate/python36.dll
pythonhome: C:/Users/username/AppData/Local/r-miniconda/envs/r-reticulate
version: 3.6.10 |Anaconda, Inc.| (default, Jan 7 2020, 15:18:16) [MSC v.1916 64 bit (AMD64)]
Architecture: 64bit
numpy: C:/Users/username/AppData/Local/r-miniconda/envs/r-reticulate/Lib/site-packages/numpy
numpy_version: 1.18.1
Now, when I call the Python script
py_run_file("PythonScript.py")
I hit the following error in R
Error in py_run_file_impl(file, local, convert) :
ModuleNotFoundError: No module named 'requests'
I understand that I need to install requests package but how do I make this in the specific Python version I've initialized?
~/AppData/Local/r-minicondafor thecondaexecutable, can you then runconda install requests? I don't have that distro of miniconda here so I cannot test it easily, but that seems like one reasonable approach. Another (perhaps more of a "best practice") would be to use a virtual environment and make sure the packages you need are installed and maintained.C:/...is exclusive to Windows. Correct me if I am wrong.reticulate.