0

I am following the instructions here to install packages (I'm looking at the "Simple Installation") section: https://rstudio.github.io/reticulate/articles/python_packages.html

Here is my R code:

library(reticulate)
use_python(python="C:\\Users\\...\\AppData\\Local\\Programs\\Python\\Python39\\python.exe")
py_install("pandas")

However, I'm getting the following error:

Error: could not find a Python environment for 
C:/Users/.../AppData/Local/Programs/Python/Python39/python.exe

How do I resolve this? I have used py_install() this way on another computer before, so I know it's possible and I would like to use it. However, I can't understand what I'm missing.

You might respond that I need to specify an environment when using py_install(), but the instructions in the link don't require that, and I know it can be done without specifying an environment every time. Do I need to somehow set a "default"?

EDIT: Just to clarify, I am on Windows.

Vladimir Belik
  • 280
  • 1
  • 12

1 Answers1

1

You may not be connected to the proper environment. Depending on your OS, you will likely have to create a .Renviron file and direct R to look for it.

This post here, should help you diagnose the issue:

Unable to change Python path in reticulate

Bryan Butler
  • 1,750
  • 1
  • 19
  • 19
  • Sorry I didn't clarify, but I'm on Windows. The link appears to be for Mac OS, is that correct? – Vladimir Belik Jan 11 '22 at 17:07
  • You can create an .Renviron file in your Documents directory and specify the `RETICULATE_PYTHON="C:/ProgramData/Anaconda3/envs/reticulate"` or wherever your reticulate environment resides. It's best to create a separate Python environment for reticulate by cloning your base and then you'll want to install PyQt5. – Bryan Butler Jan 11 '22 at 19:38