rstudio / reticulate

R Interface to Python
https://rstudio.github.io/reticulate
Apache License 2.0
1.67k stars 327 forks source link

Can not change the version of python #1220

Closed Lee0498 closed 8 months ago

Lee0498 commented 2 years ago

When I tried to change the version of python, I got followed message.

ERROR: The requested version of Python ('/home/lcy/.local/share/r-miniconda/envs/giotto_env/bin/python') cannot be used, as another version of Python ('/home/lcy/.local/share/r-miniconda/envs/r-reticulate/bin/python') has already been initialized. Please restart the R session if you need to attach reticulate to a different version of Python. Error in reticulate::use_python(required = T, python = python_path) : failed to initialize requested version of Python

Lee0498 commented 2 years ago

I restarted my R session as instruction, but it didn't work.

HomeStayMom commented 1 year ago

Hi, I am having the same issue. I wish to explicitly state with use_condaenv("1st_python") the conda env I wish to utilize. Traceback shows:\ ERROR: The requested version of Python ('C:\Users\info\AppData\Local\r-miniconda\envs\1st_python/python.exe') cannot be used, as another version of Python ('C:/Users/info/AppData/Local/Programs/Python/Python311/python.exe') has already been initialized. Please restart the R session if you need to attach reticulate to a different version of Python. The traceback

  1. | stop("failed to initialize requested version of Python")
  2. | use_python(python, required = required)
  3. | use_condaenv("1st_python")
t-kalinowski commented 1 year ago

If you're seeing this error, this is the key section:

The requested version of Python cannot be used, as another version of Python has already been initialized. Please restart the R session if you need to attach reticulate to a different version of Python.

You can restart the R session in the RStudio IDE through the keyboard shortcut Ctrl+Shift+F10, or navigating in the Menu to "Session" -> "New Session".

If that doesn't fix the issue, then you have to figure out what is causing reticulate to initialize. Some common places to looks:

HomeStayMom commented 1 year ago

Hi , I found a solution : in RStudio >Tools>Global Options>Python>Select. Here two options either check or uncheck the box with Automatically activate project-local Python environment.

On Tue, 21 Feb 2023 at 17:48, Tomasz Kalinowski @.***> wrote:

If you're seeing this error, this is the key section:

The requested version of Python cannot be used, as another version of Python has already been initialized. Please restart the R session if you need to attach reticulate to a different version of Python.

You can restart the R session in the RStudio IDE through the keyboard shortcut Ctrl+Shift+F10, or navigating in the Menu to "Session" -> "New Session".

If that doesn't fix the issue, then you have to figure out what is causing reticulate to initialize. Some common places to looks:

  • Something in the files "~/.Rprofile" or ".Rprofile"
  • The IDE or R front-end initializing reticulate as part of its startup routine (e.g., if you're using R through radian, or have the RStudio IDE configured to use Python).

— Reply to this email directly, view it on GitHub https://github.com/rstudio/reticulate/issues/1220#issuecomment-1438707815, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXAZUSU43Y6OC4LFFNFRHPDWYTPUTANCNFSM5XDD7S2Q . You are receiving this because you commented.Message ID: @.***>

olympus-terminal commented 1 year ago

HomeStayMom's solution worked for me to change Python versions on macOS Monterey and Rstudio Build 492