Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UV lists python interpreters but can't use them! #9668

Closed
meitham opened this issue Dec 6, 2024 · 7 comments · Fixed by #9736
Closed

UV lists python interpreters but can't use them! #9668

meitham opened this issue Dec 6, 2024 · 7 comments · Fixed by #9736
Labels
bug Something isn't working

Comments

@meitham
Copy link

meitham commented Dec 6, 2024

I'm on version uv 0.5.6 (b70c4f3 2024-12-03) on windows
uv sees my python interpreters from the windows registry

C:\Temp>uv python list
cpython-3.13.0+freethreaded-windows-x86_64-none    <download available>
cpython-3.12.7-windows-x86_64-none                 <download available>
cpython-3.12.2-windows-x86_64-none                 D:\apps\Python\Python312\python.exe
cpython-3.11.10-windows-x86_64-none                <download available>
cpython-3.10.15-windows-x86_64-none                <download available>
cpython-3.9.20-windows-x86_64-none                 <download available>
cpython-3.9.13-windows-x86_64-none                 D:\apps\python\Python39\python.exe
cpython-3.9.12-windows-x86_64-none                 C:\ProgramData\Miniconda3\python.exe
cpython-3.8.20-windows-x86_64-none                 <download available>
cpython-3.7.9-windows-x86_64-none                  <download available>
cpython-3.7.6-windows-x86_64-none                  C:\apps\python37\python.exe
pypy-3.10.14-windows-x86_64-none                   <download available>
pypy-3.9.19-windows-x86_64-none                    <download available>
pypy-3.8.16-windows-x86_64-none                    <download available>
pypy-3.7.13-windows-x86_64-none                    <download available>

But when I try and use one of them uv complains it does not exists

C:\Temp>uv venv --python 3.9.13 orion --seed --no-python-downloads
  x No interpreter found for Python 3.9.13 in managed installations, search path, or registry

I think the uv venv command does not use the same discover mechanism as the uv list

@meitham meitham changed the title UV lists python interpreters but cannnot use them! UV lists python interpreters but can't use them! Dec 6, 2024
@zanieb
Copy link
Member

zanieb commented Dec 6, 2024

That's surprising. Can you share the --verbose logs for uv venv? It may be helpful to include trace logs which include additional information about interpreter selection RUST_LOG=uv=trace

@zanieb zanieb added the bug Something isn't working label Dec 6, 2024
@meitham
Copy link
Author

meitham commented Dec 6, 2024

sure, here's the verbose uv venv output

C:\Temp>set RUST_LOG=uv=trace
C:\Temp>uv venv --python 3.9.13 orion --seed --no-python-downloads -vvv --color never
    0.000034s ←[1;34mDEBUG←[0m ←[2muv←[0m uv 0.5.6 (b70c4f30e 2024-12-03)
    0.001026s ←[1;34mDEBUG←[0m ←[2muv::commands::project←[0m Using Python request `3.9.13` from explicit request
    0.002073s ←[1;34mDEBUG←[0m ←[2muv_python::discovery←[0m Searching for Python 3.9.13 in managed installations, search path, or registry
    0.004770s ←[1;34mDEBUG←[0m ←[2muv_python::discovery←[0m Searching for managed installations at `C:\Users\mjamaa\AppData\Roaming\uv\python`
    0.005384s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Searching PATH for executables: python3.9.13.exe, python3.9.exe, python3.exe, python.exe
    0.005883s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: D:\apps\miniconda3\condabin
    0.006535s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Program Files (x86)\Common Files\Oracle\Java\java8path
    0.007145s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\WINDOWS\system32
    0.007558s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\WINDOWS
    0.008057s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\WINDOWS\System32\Wbem
    0.008461s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    0.008878s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Program Files\Azure Data Studio\bin
    0.009268s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\ProgramData\chocolatey\bin
    0.009692s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Program Files\Microsoft SQL Server\150\Tools\Binn\
    0.010100s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Program Files\dotnet\
    0.010507s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Program Files\TortoiseSVN\bin
    0.010923s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\
    0.011343s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Program Files\Docker\Docker\resources\bin
    0.011764s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Program Files\nodejs\
    0.012155s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Users\mjamaa\.local\bin
    0.012568s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: D:\apps\Python\Python312\Scripts\
    0.012964s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: D:\apps\Python\Python312\
    0.013459s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Found possible Python executable: D:\apps\Python\Python312\python.exe
    0.013911s ←[1;35mTRACE←[0m ←[2muv_python::interpreter←[0m Cached interpreter info for Python 3.12.2, skipping probing: D:\apps\Python\Python312\python.exe
    0.014111s ←[1;34mDEBUG←[0m ←[2muv_python::discovery←[0m Found `cpython-3.12.2-windows-x86_64-none` at `D:\apps\Python\Python312\python.exe` (search path)
    0.018863s ←[1;34mDEBUG←[0m ←[2muv_python::discovery←[0m Skipping interpreter at `D:\apps\Python\Python312\python.exe` from search path: does not satisfy request `3.9.13`
    0.019425s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Users\mjamaa\AppData\Local\Programs\Python\Launcher\
    0.019980s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Users\mjamaa\AppData\Local\Programs\Python\Python311
    0.020450s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\Users\mjamaa\AppData\Local\Microsoft\WindowsApps
    0.021379s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\opt\unixutils\usr\local\wbin
    0.021741s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: c:\opt\sysinternals
    0.022162s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: c:\opt\bin
    0.022564s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: c:\opt\cmder
    0.023009s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: c:\opt\nmap-7.92
    0.023426s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\apps\vscode\bin
    0.023816s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: D:\apps\miniconda3\Scripts
    0.024258s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\opt\nvim-win64\bin
    0.024667s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\opt\unixutils\usr\local\wbin
    0.025087s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\opt\bin
    0.025499s ←[1;35mTRACE←[0m ←[2muv_python::discovery←[0m Checking `PATH` directory for interpreters: C:\opt\emacs-28.1\bin
    0.026157s ←[1;34mDEBUG←[0m ←[2muv_python::py_launcher←[0m Python interpreter in the registry is not executable: `Software\Python\PythonCore\3.9
  x No interpreter found for Python 3.9.13 in managed installations, search path, or registry

@aDotInTheVoid

This comment has been minimized.

@zanieb
Copy link
Member

zanieb commented Dec 6, 2024

@aDotInTheVoid that's unrelated — the above issue is related to the Windows registry — could you open a new issue instead?

@meitham There's an error

Python interpreter in the registry is not executable: `Software\Python\PythonCore\3.9

This comes from the check at

let Ok(executable_path) = tag_key
.open("InstallPath")
.and_then(|install_path| install_path.get_value("ExecutablePath"))
.and_then(String::try_from)
else {
debug!(
r"Python interpreter in the registry is not executable: `Software\Python\{}\{}",
company, tag
);
return None;
};

I'm not sure what would cause that, @konstin may know.

Does it work for other Python versions like 3.12?

@konstin
Copy link
Member

konstin commented Dec 6, 2024

Can you share the output of Get-ChildItem -Path "HKCU:\Software\Python" -Recurse -Depth 2 and/or Get-ChildItem -Path "HKLM:\Software\Python" -Recurse -Depth 2?

Currently puzzled by how the 3.9.13 is shown in the list but then can't be used, we use the same code path for listing and deciding on which interpreter to execute.

@meitham
Copy link
Author

meitham commented Dec 7, 2024

Please see below my registry. I think I see what the issue is, I have python 3.9.12 (miniconda) and python 3.9.13 (psf) but in the windows registry their patch version is omitted so they both appear as 3.9. Though one was installed by admin so it went into current machine, and the other is in current user.


Hive: HKEY_CURRENT_USER\Software\Python


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
PyLauncher                     InstallDir     : C:\Users\mjamaa\AppData\Local\Programs\Python\Launcher\                                                                                                                       
                               AssociateFiles : 1                                                                                                                                                                             
                               (default)      : C:\Users\mjamaa\AppData\Local\Programs\Python\Launcher\py.exe                                                                                                                 
PythonCore                     DisplayName : Python Software Foundation                                                                                                                                                       
                               SupportUrl  : https://www.python.org/                                                                                                                                                          


    Hive: HKEY_CURRENT_USER\Software\Python\PythonCore


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
3.12                           DisplayName     : Python 3.12 (64-bit)                                                                                                                                                         
                               SupportUrl      : https://www.python.org/                                                                                                                                                      
                               Version         : 3.12.2                                                                                                                                                                       
                               SysVersion      : 3.12                                                                                                                                                                         
                               SysArchitecture : 64bit                                                                                                                                                                        


    Hive: HKEY_CURRENT_USER\Software\Python\PythonCore\3.12


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
Help                                                                                                                                                                                                                          
Idle                           (default) : D:\apps\Python\Python312\Lib\idlelib\idle.pyw                                                                                                                                      
IdleShortcuts                  (default) : 1                                                                                                                                                                                  
InstalledFeatures              Shortcuts    : 3.12.2150.0                                                                                                                                                                     
                               exe          : 3.12.2150.0                                                                                                                                                                     
                               dev          : 3.12.2150.0                                                                                                                                                                     
                               lib          : 3.12.2150.0                                                                                                                                                                     
                               test         : 3.12.2150.0                                                                                                                                                                     
                               doc_shortcut : 3.12.2150.0                                                                                                                                                                     
                               doc          : 3.12.2150.0                                                                                                                                                                     
                               tcltk        : 3.12.2150.0                                                                                                                                                                     
                               pip          : 3.12.2150.0                                                                                                                                                                     
                               path         : 3.12.2150.0                                                                                                                                                                     
InstallPath                    (default)              : D:\apps\Python\Python312\                                                                                                                                             
                               ExecutablePath         : D:\apps\Python\Python312\python.exe                                                                                                                                   
                               WindowedExecutablePath : D:\apps\Python\Python312\pythonw.exe                                                                                                                                  
PythonPath                     (default) : D:\apps\Python\Python312\Lib\;D:\apps\Python\Python312\DLLs\                                                                                                                       


    Hive: HKEY_CURRENT_USER\Software\Python\PythonCore


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
3.7                            DisplayName     : Python 3.7 (64-bit)                                                                                                                                                          
                               SupportUrl      : http://www.python.org/                                                                                                                                                       
                               Version         : 3.7.6                                                                                                                                                                        
                               SysVersion      : 3.7                                                                                                                                                                          
                               SysArchitecture : 64bit                                                                                                                                                                        


    Hive: HKEY_CURRENT_USER\Software\Python\PythonCore\3.7


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
Help                                                                                                                                                                                                                          
Idle                           (default) : C:\apps\python37\Lib\idlelib\idle.pyw                                                                                                                                              
IdleShortcuts                  (default) : 1                                                                                                                                                                                  
InstalledFeatures              dev          : 3.7.6150.0                                                                                                                                                                      
                               Shortcuts    : 3.7.6150.0                                                                                                                                                                      
                               exe          : 3.7.6150.0                                                                                                                                                                      
                               lib          : 3.7.6150.0                                                                                                                                                                      
                               test         : 3.7.6150.0                                                                                                                                                                      
                               doc_shortcut : 3.7.6150.0                                                                                                                                                                      
                               doc          : 3.7.6150.0                                                                                                                                                                      
                               tools        : 3.7.6150.0                                                                                                                                                                      
                               tcltk        : 3.7.6150.0                                                                                                                                                                      
                               pip          : 3.7.6150.0                                                                                                                                                                      
InstallPath                    (default)              : C:\apps\python37\                                                                                                                                                     
                               ExecutablePath         : C:\apps\python37\python.exe                                                                                                                                           
                               WindowedExecutablePath : C:\apps\python37\pythonw.exe                                                                                                                                          
PythonPath                     (default) : C:\apps\python37\Lib\;C:\apps\python37\DLLs\                                                                                                                                       


    Hive: HKEY_CURRENT_USER\Software\Python\PythonCore


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
3.9                            DisplayName     : Python 3.9 (64-bit)                                                                                                                                                          
                               SupportUrl      : https://www.python.org/                                                                                                                                                      
                               Version         : 3.9.13                                                                                                                                                                       
                               SysVersion      : 3.9                                                                                                                                                                          
                               SysArchitecture : 64bit                                                                                                                                                                        


    Hive: HKEY_CURRENT_USER\Software\Python\PythonCore\3.9


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
Help                                                                                                                                                                                                                          
Idle                           (default) : D:\apps\python\Python39\Lib\idlelib\idle.pyw                                                                                                                                       
IdleShortcuts                  (default) : 1                                                                                                                                                                                  
InstalledFeatures              dev          : 3.9.13150.0                                                                                                                                                                     
                               Shortcuts    : 3.9.13150.0                                                                                                                                                                     
                               exe          : 3.9.13150.0                                                                                                                                                                     
                               lib          : 3.9.13150.0                                                                                                                                                                     
                               test         : 3.9.13150.0                                                                                                                                                                     
                               doc_shortcut : 3.9.1150.0                                                                                                                                                                      
                               doc          : 3.9.1150.0                                                                                                                                                                      
                               tools        : 3.9.13150.0                                                                                                                                                                     
                               tcltk        : 3.9.13150.0                                                                                                                                                                     
                               pip          : 3.9.13150.0                                                                                                                                                                     
InstallPath                    (default)              : D:\apps\python\Python39\                                                                                                                                              
                               ExecutablePath         : D:\apps\python\Python39\python.exe                                                                                                                                    
                               WindowedExecutablePath : D:\apps\python\Python39\pythonw.exe                                                                                                                                   
Modules                        (default) :                                                                                                                                                                                    
PythonPath                     (default) : D:\apps\python\Python39\Lib\;D:\apps\python\Python39\DLLs

and My Local Machine


Hive: HKEY_LOCAL_MACHINE\Software\Python


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
ContinuumAnalytics             DisplayName : Continuum Analytics, Inc.                                                                                                                                                        
                               SupportUrl  : https://github.com/continuumio/anaconda-issues                                                                                                                                   


    Hive: HKEY_LOCAL_MACHINE\Software\Python\ContinuumAnalytics


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
Anaconda39-64                  DisplayName     : Anaconda py39_4.12.0                                                                                                                                                         
                               SupportUrl      : https://github.com/continuumio/anaconda-issues                                                                                                                               
                               Version         : py39_4.12.0                                                                                                                                                                  
                               SysVersion      : 3.9                                                                                                                                                                          
                               SysArchitecture : 64bit                                                                                                                                                                        


    Hive: HKEY_LOCAL_MACHINE\Software\Python\ContinuumAnalytics\Anaconda39-64


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
Help                                                                                                                                                                                                                          
InstallPath                    (default)              : C:\ProgramData\Miniconda3                                                                                                                                             
                               ExecutablePath         : C:\ProgramData\Miniconda3\python.exe                                                                                                                                  
                               WindowedExecutablePath : C:\ProgramData\Miniconda3\pythonw.exe                                                                                                                                 
Modules                        (default) :                                                                                                                                                                                    
PythonPath                     (default) : C:\ProgramData\Miniconda3\Lib;C:\ProgramData\Miniconda3\DLLs                                                                                                                       


    Hive: HKEY_LOCAL_MACHINE\Software\Python


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
PythonCore                                                                                                                                                                                                                    


    Hive: HKEY_LOCAL_MACHINE\Software\Python\PythonCore


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
3.9                                                                                                                                                                                                                           


    Hive: HKEY_LOCAL_MACHINE\Software\Python\PythonCore\3.9


Name                           Property                                                                                                                                                                                       
----                           --------                                                                                                                                                                                       
Help                                                                                                                                                                                                                          
InstallPath                    (default) : C:\ProgramData\Miniconda3                                                                                                                                                          
Modules                        (default) :                                                                                                                                                                                    
PythonPath                     (default) : C:\ProgramData\Miniconda3\Lib;C:\ProgramData\Miniconda3\DLLs

konstin added a commit that referenced this issue Dec 9, 2024
Previously, `-vvv --color never` would still emit ANSI sequences to stderr.

Ref #9668 (comment)
konstin added a commit that referenced this issue Dec 9, 2024
Previously, `-vvv --color never` would still emit ANSI sequences to
stderr.

Ref #9668 (comment)
konstin added a commit that referenced this issue Dec 9, 2024
The `SysVersion` registry entry may or may not include the patch
version, so if we encounter a registry entry without a patch version, we
must not assume that the patch version is 0.

```
Name                           Property
----                           --------
3.9                            DisplayName     : Python 3.9 (64-bit)
                               SupportUrl      : https://www.python.org/
                               Version         : 3.9.13
                               SysVersion      : 3.9
                               SysArchitecture : 64bit

    Hive: HKEY_CURRENT_USER\Software\Python\PythonCore\3.9
```

Confirmed the fix manually.

Fixes #9668
@meitham
Copy link
Author

meitham commented Dec 9, 2024

Thank you for fixing this, and special thanks for fixing the colors issue ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants