How to reset py's database?

59 Views Asked by At

A vscode extension needs to use py launcher. I installed Python via scoop and it works:

PS C:\Users\W> python --version
Python 3.12.1

When checking for py, it is where it is expected to be:

PS C:\Users\W> Get-Command py

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     py.exe                                             3.12.1150… C:\Users\W\scoop\apps\python\current\py.exe

So far so good. Now when I actually want to launch py I get

PS C:\Users\W> py
Unable to create process using 'C:\Users\W\scoop\apps\python\3.11.3\python.exe': The system cannot find the file specified.

py seems to point to an old version that I may have had in the past.

I uninstalled Python, checked that py is now unknown, and reinstalled it afterwards. The effect is the same - this information must have been saved somewhere, and worse, this is the only Python installation py knows about:

PS C:\Users\W> py --list
 -V:3.11 *        Python 3.11 (64-bit)

3.11 is nowhere to be found and py.exe directly comes from the 3.12 installation

PS C:\Users\W> ls C:\Users\W\scoop\apps\python

    Directory: C:\Users\W\scoop\apps\python

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          21/12/2023    17:35                3.12.1
l-r--          21/12/2023    17:35                current -> C:\Users\W\scoop\apps\python\3.12.1

I am now at the end of my journey to try to understand where th eproblem is, thus my question: how to reset the py database of installed Python versions?

1

There are 1 best solutions below

0
WoJ On

I searched the Registry for 3.11.3, found it at HKEY_USERS\<my user UID>\Software\Python\PythonCore\3.11.3 and removed completely.

py then could not find any installation.

I then uninstalled/installed Python (via scoop) and still no available installation according to py.

The scoop install provides at the end a .reg file that populates the Registry path above (somehow it did not propose it with my previous installations).

Adding the Registry entry finally fixed the issue

PS C:\Users\W> py
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

I belive that this issue will be specific to scoop installations, I will update the tags.