RStudio not recognizing Python path

Hi everyone! I'm trying to use my existing installation of Python 3.11 with RStudio on Windows 11. I've set this up before in Linux without issues, but in Windows it doesn't recognize the filepath I give Global Options nor in the console. Can anyone point out what I should be doing? Thanks!

I get the filepath to the python executable this way:

import os
import sys
os.path.dirname(sys.executable)
'C:\\File\\Path\\Here'

And then try to connect to it through reticulate:

library(reticulate)
use_python("C:/File/Path/Here/python3.11.exe")
Error in use_python("C:/File/Path/Here/python3.11.exe") : 
  Specified version of python 'C:/File/Path/Here/python3.11.exe' does not exist.

Are you sure that the file name is python3.11.exe ?

Your approach works for me:

>python
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Users\\me\\AppData\\Local\\Programs\\Python\\Python39'

in R:

> reticulate::use_python("C:/Users/me/AppData/Local/Programs/Python/Python39")
> reticulate::use_python("C:/Users/me/AppData/Local/Programs/Python/Python39/python.exe")

both work. And there is no exe file with a version name:

> list.files("C:/Users/me/AppData/Local/Programs/Python/Python39", pattern = "python")
[1] "python.exe"   "python3.dll"  "python39.dll" "pythonw.exe" 
1 Like

Thanks for trying to replicate this. The file exists AFAIK (it shows up both when I check in Windows Explorer and when I type in the file path in the RStudio console).
Maybe it's the file path specifically? For me it's C:\\Users\\me\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0
Does RStudio/reticulate not like system installations?

Apparently reticulate/RStudio do not like the system installation of Python that you get from the Windows Store, so either using miniconda or downloading and installing Python manually are the ways to do it.

1 Like

This topic was automatically closed 7 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.