admin管理员组文章数量:1431997
When I run py --version
on Windows, I get this error:
Unable to create process using '%LOCALAPPDATA%\Programs\Python\Python312\python.exe --version': The system cannot find the file specified.
However, I have Python properly installed in C:\Program Files\Python312\
(confirmed by where python.exe
).
Running ftype
shows the Python Launcher is installed:
Python.ArchiveFile="C:\Windows\py.exe" "%L" %*
Python.CompiledFile="C:\Windows\py.exe" "%L" %*
Python.File="C:\Windows\py.exe" "%L" %*
Python.NoConArchiveFile="C:\Windows\pyw.exe" "%L" %*
Python.NoConFile="C:\Windows\pyw.exe" "%L" %*
And py -0p --list-paths
shows:
-V:3.12 * %LOCALAPPDATA%\Programs\Python\Python312\python.exe
The launcher is looking for Python in my AppData
folder (probably from an old installation), but Python is actually installed in Program Files. How can I fix this?
When I run py --version
on Windows, I get this error:
Unable to create process using '%LOCALAPPDATA%\Programs\Python\Python312\python.exe --version': The system cannot find the file specified.
However, I have Python properly installed in C:\Program Files\Python312\
(confirmed by where python.exe
).
Running ftype
shows the Python Launcher is installed:
Python.ArchiveFile="C:\Windows\py.exe" "%L" %*
Python.CompiledFile="C:\Windows\py.exe" "%L" %*
Python.File="C:\Windows\py.exe" "%L" %*
Python.NoConArchiveFile="C:\Windows\pyw.exe" "%L" %*
Python.NoConFile="C:\Windows\pyw.exe" "%L" %*
And py -0p --list-paths
shows:
-V:3.12 * %LOCALAPPDATA%\Programs\Python\Python312\python.exe
The launcher is looking for Python in my AppData
folder (probably from an old installation), but Python is actually installed in Program Files. How can I fix this?
1 Answer
Reset to default 0This issue occurs when Python launcher registration points to an old/removed Python installation. The problem is in the Windows Registry, where Python is registered in both HKEY_CURRENT_USER
(user-specific) and HKEY_LOCAL_MACHINE
(system-wide) pointing to different locations.
You can verify this by checking both registry locations:
reg query "HKEY_CURRENT_USER\Software\Python\PythonCore" /s
reg query "HKEY_LOCAL_MACHINE\Software\Python\PythonCore" /s
In my case:
HKEY_CURRENT_USER
pointed to:%LOCALAPPDATA%\Programs\Python\Python312
(non-existent)HKEY_LOCAL_MACHINE
pointed to:C:\Program Files\Python312
(correct location)
Solution:
Run these commands in an administrator CMD to remove the incorrect user-specific registration:
reg delete "HKEY_CURRENT_USER\Software\Python\PythonCore\3.12" /f
reg delete "HKEY_CURRENT_USER\Software\Python\PythonCore" /f
After this, the Python launcher will use the correct system-wide registration from HKEY_LOCAL_MACHINE.
Verify the fix:
py --version
should now work correctlypy -0p --list-paths
should show the Program Files locationreg query "HKEY_CURRENT_USER\Software\Python\PythonCore" /s
should find nothing
Why this happens:
This typically occurs when you:
- First install Python for the current user only (goes to
AppData
) - Later uninstall it
- Then install Python for all users (goes to Program Files)
The old user-specific registry entries may remain, causing the Python launcher to look in the wrong location.
Alternative Solution:
If you prefer a fresh start, you could:
- Uninstall Python completely
- Delete any remaining Python folders in AppData
- Reinstall Python with:
- "Install for all users" checked (installs to Program Files)
- "Add Python to PATH" checked
This will ensure clean registry entries.
本文标签:
版权声明:本文标题:windows - Python Launcher (py.exe) points to non-existent Python installation in AppData - how to fix? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745565824a2663753.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论