Reticulate - Error: could not find a Python environment for

I have just updated my RStudio to version 2021.09.1, but it is impossible to work with Python through reticulate (machine: Windows 10). Error: could not find a Python environment for C:/Users/user/AppData/Local/r-miniconda/python.exe

After updating to the latest RStudio version, I tried to work on Python scripts as I used to do before the update.

I had first this issue:

> reticulate::repl_python()
Error in python_config(python_version, required_module, forced = "RETICULATE_PYTHON") : 
  Error 1033 occurred running C:/Users/user/AppData/Local/r-miniconda/envs/r-reticulate/python.exe 
In addition: Warning message:
In system2(command = python, args = shQuote(config_script), stdout = TRUE,  :
  running command '"C:/Users/user/AppData/Local/r-miniconda/envs/r-reticulate/python.exe" "C:/Users/user/Documents/R/win-library/4.1/reticulate/config/config.py"' had status 1033

This is what I have done so far:

  1. I decided to re-install r-miniconda by installing again reticulate. This did not solve the issue.
  2. I then checked in the global options and I found out that python interpreter was not configured.
    Within Conda Environment I have selected Python 3.9.5

now It seems to work:

> reticulate::repl_python()
Python 3.9.5 (C:/Users/Luca/AppData/Local/r-miniconda/python.exe)
Reticulate 1.22 REPL -- A Python interpreter in R.
Enter 'exit' or 'quit' to exit the REPL and return to R.

However, after calling the library(reticulate) from Rscript I tried to install Python modules (e.g., xarray) , but it returns:


> py_install(xarray)
Error: could not find a Python environment for C:/Users/user/AppData/Local/r-miniconda/python.exe

I do not understand why R does not find the path. It exists and it is linked to reticulate:

> reticulate::py_config()
python:         C:/Users/user/AppData/Local/r-miniconda/python.exe
libpython:      C:/Users/user/AppData/Local/r-miniconda/python39.dll
pythonhome:     C:/Users/user/AppData/Local/r-miniconda
version:        3.9.5 (default, May 18 2021, 14:42:02) [MSC v.1916 64 bit (AMD64)]
Architecture:   64bit
numpy:           [NOT FOUND]

NOTE: Python version was forced by RETICULATE_PYTHON

Update:
I tried to install again miniconda and this is what I get at the end:

* Miniconda has been successfully installed at "C:/Users/user/AppData/Local/r-miniconda".
Error in python_config(miniconda_python, NULL, miniconda_python) : 
  Error 1033 occurred running C:/Users/user/AppData/Local/r-miniconda/envs/r-reticulate/python.exe 
In addition: Warning message:
In system2(command = python, args = shQuote(config_script), stdout = TRUE,  :
  running command '"C:/Users/user/AppData/Local/r-miniconda/envs/r-reticulate/python.exe" "C:/Users/user/Documents/R/win-library/4.1/reticulate/config/config.py"' had status 1033

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.