Skip to content

fix(interpreter): verify py launcher path exists before returning#1728

Draft
BillionClaw wants to merge 1 commit intopypa:mainfrom
BillionClaw:clawoss/fix/windows-py-launcher-stale-path
Draft

fix(interpreter): verify py launcher path exists before returning#1728
BillionClaw wants to merge 1 commit intopypa:mainfrom
BillionClaw:clawoss/fix/windows-py-launcher-stale-path

Conversation

@BillionClaw
Copy link
Copy Markdown
Contributor

The Windows py launcher can return stale registry entries for Python versions that have been uninstalled or moved. This causes pipx to fail with "did not find executable at path" errors when trying to use the returned path.

Added a check to verify the path returned by the py launcher actually exists on disk before returning it from find_py_launcher_python().

Fixes #1723

The Windows py launcher can return stale registry entries for
uninstalled Python versions. Added a check to verify the returned
path actually exists before using it.

Fixes pypa#1723
@dukecat0
Copy link
Copy Markdown
Member

Please fix this error:

PLC0415 `import` should be at the top-level of a file
   --> tests/test_interpreter.py:210:5
    |
208 |     causing the py launcher to return stale paths.
209 |     """
210 |     from pipx.interpreter import find_py_launcher_python
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
211 |
212 |     def which(name):
    |

Found 1 error.

InterpreterResolutionError,
_find_default_windows_python,
_get_absolute_python_interpreter,
find_python_interpreter,
Copy link
Copy Markdown
Contributor

@cclauss cclauss Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put that find_py_launcher_python import here to placate the linter.

@gaborbernat gaborbernat marked this pull request as draft March 17, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"did not find executable at 'C:\Users\X\AppData\Local\Programs\Python\Python314\python.exe'" on Windows

3 participants