question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pip brings harcoded python 3.8 path (doesn't run with any newer python version)

See original GitHub issue

Description

Currently, we’re on python 3.9.7. If you check the install options in the official python installer, it already comes with pip.

The problem is you can’t run pip on any fresh install of Python 3.9.x, you’ll get the error:

Fatal error in launcher: Unable to create process using '"c:\program files\python38\python.exe" "C:\Program Files\Python38\Scripts\pip.exe" --version': The system cannot find the file specified.

As it turns out, the internet (e.g StackOverflow) is now laden with complaints about this issue. Many people assume it’s related to PATH/environment varibles misconfiguration, but it has nothing to do with it.

I was convinced it was some issue with pip itself, because it was looking for the Python 3.8, something I never installed on my PC, as well as it was looking into the path where pip itself was installed.

As it turns out, I opened the pip.exe binary found under C:\Program Files\Python38\ in a hex editor, found the aforementioned path there and changed it to my actual Python 3.9 path and now it works as it should.

Expected behavior

pip should read Python’s path from my enviroment variables, rather than bringing a hardcoded Python 3.8 path (which btw isn’t even the default Python 3.8 install path)

pip version

21.2.4

Python version

3.9.7

OS

Windows 10 x64 2004

How to Reproduce

  1. Download Python 3.9.x from https://www.python.org/
  2. Install Python 3.9.7
  3. Open cmd/powershell and try invoking the command pip

Output

Fatal error in launcher: Unable to create process using '"c:\program files\python38\python.exe"  "C:\Program Files\Python38\Scripts\pip.exe" --version': The system cannot find the file specified.

Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
pfmoorecommented, Dec 3, 2021

This is by design. When an executable wrapper is contained (either for pip, or for any other package that pip installs) we hard code the exact path to the Python interpreter that the package is installed into. This is to ensure that the command is run using the Python interpreter that has the necessary dependencies installed.

If you use the executable wrapper for pip (rather than the recommended approach of using py -m pip) then you should always use the wrapper installed in the Python installation you want to run pip against.

0reactions
mkhoncommented, Dec 2, 2021

Actual problem is that on Windows pip embeds full paths into scripts (pip.exe is a compiled script itself).

See #10700

Read more comments on GitHub >

github_iconTop Results From Across the Web

pip3: bad interpreter: No such file or directory - Stack Overflow
The simplest thing to do is to just rm /usr/local/bin/pip3 . Then, assuming you want your Homebrew Python to be your default for...
Read more >
Could we add Python to system PATH by default? - Ideas
When installing python for Windows, I see a checkbox that gives an option of adding it to the 'PATH' which I presume is...
Read more >
Python 3 Installation & Setup Guide
In this tutorial you'll learn how to: Check which version of Python, if any, is installed on your machine; Install or update Python...
Read more >
Setting up your python development environment (with pyenv ...
You might have some working Python code and want to make sure everything stays ... gives python 2 and not python 3: brew...
Read more >
How to Install Pip on Windows - ActiveState
One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found