How to fix Windows system incorrectly assuming python.exe path?

64 views Asked by At

I'm trying to run a pip installation on my Windows machine using the command:

pip install -r requirements.txt

But when I try to execute that command, I get the following error:

Fatal error in launcher: Unable to create process using '"C:\Program Files\Inkscape\bin\python.exe"  "C:\Users\[my user]\.local\bin\pip.exe" install -r requirements.txt': The system cannot find the file specified.

The evident thing here is that it's looking for the python.exe file in an incorrect folder.

This folder used to be in the PATH environment variable for my user, and I've since removed it. I've also reinstalled Python without that folder in the PATH variable, but even then I still get that error. Is there a manual way to tell the system specifically that python.exe is in the \AppData\Local\Programs\Python\Python312\ path and not the one it assumes it is in? I also followed the instructions in the best answer to this question made prior in the site.

EDIT: using where python yields the following:

C:\Users\[my user]\AppData\Local\Microsoft\WindowsApps\python.exe

EDIT 2: using echo %PATH% does show the folders that contain python.exe and pip.exe.

By the way, there is in fact a pip.exe in the path the error provides.

1

There are 1 answers

1
Michael Butscher On

The pip.exe file consists of a simple launcher stub executable, followed by a shebang line containing the path to the actual launcher (to the wrong python.exe in this case) and finally a ZIP-file containing a python script which should be executed by the python executable.

Details about the launcher stub can be found at https://bitbucket.org/vinay.sajip/simple_launcher/src/master/

If the shebang line contains the absolute path (usually this is the case and seems the case here), playing around with the PATH environment variable won't do anything as long as the same pip.exe is launched.

Solution is to find the pip.exe which was installed with your Python version (should be in a directory Scripts below the python.exe). You can copy this pip.exe and replace the C:\Users\[my user]\.local\bin\pip.exe with it.

The slightly more complicated option would be to modify the pip.exe with a hex editor to set the right path.