Vladimir Belik
Vladimir Belik

Reputation: 400

Reticulate package, cannot install Python packages using py_install()

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.

Upvotes: 0

Views: 2013

Answers (1)

Bryan Butler
Bryan Butler

Reputation: 1850

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

Upvotes: 1

Related Questions