Skip to content Skip to sidebar Skip to footer

Pipenv Failing To Install Packages

So this error happened after I uninstalled Python 3.7.4 for the newer Python 3.8.3. I try to use pipenv install and this is what it outputs: PS C:\Users\enoch\Documents\spectral_cu

Solution 1:

I got the same problem. You can try to go to regedit, and find the key word "python-3.7.4", delete all of them, and retry.

Solution 2:

Met the exact same error. Ultimately, I solved this problem by simply deleting the duplicate python version using control panel. But since you have already deleted the older version, then here is what I have been through, hope it would help.


Python.py

Since the traceback is all about a wrong path, I followed the error message and dug into this pythonfinder\models\python.py file. In there I found a method called parse_executable(cls, path). I threw a print(path) in and it seems that the path variable was printed twice.

  • One for the normal python in my PATH.
  • Another for the old python path, python2.x, even it is not in my PATH variable

I play around with this file for a while, trying to figure out how the path is created and why it includes the zombie python2.x version that's not even a valid python path.

Though barely understand the logic, I thought what happened would be like:

  • parse_executable() > python 3.8 >
  • check another version > parse_executable() > python 2.x > traceback

Registries

In order to solve the problem, I started to browse the internet. And this blog pointed out how the registry could come into play.

I followed this answer and found the registries related to python in my machine are completely wrong. My python version should be 3.8, but it is 2.x

enter image description here

So I deleted all the python. registries. The data in them is wrong.

enter image description here

This may not be recommended and I am sorry I can't explain this well. Because I just thought this could be related without considering how important the registries are... You can refer to this post to find out how to do.

Desperate shots

After that, pipenv was still not working. And this parse_executable(cls, path) still printed two paths. I tried a lot to make sure that the python2.x was not in any possible paths.

  • I deleted {user}\AppData\Local\Programs\Python folder.
  • I deleted {user}\AppData\Local\Roaming\Python37 folder.(I didn't know it exists...)

But still, python2.x was considered by python.py.

After all the struggling, I figured maybe this is not the issue about path, but the existing of a program. So I uninstalled the python2.x version in my machine. Surprisingly this desperate shot worked at last.

In short, I think the problem is incompletely uninstall the older python version, which may include the registries. I hope this could provide you a hint of why this error happened and how to solve it completely.

ps: I am still curious about how python.py could find the version of python2.x which is not in any environment variables.

Solution 3:

I hope this could save someone's time. My machine OS is Windows 10. I had the same problem, and the problem was caused by renamed executable, namely python.exe was named as python2.exe. The module python.py looks for python.exe in default locations, and after not finding it there raises the exception. So the solution in my case was to change the name to python.exe.

To see the default location of each python version use the following code:

>>> import os
>>> import sys
>>> print(os.path.dirname(sys.executable))

If you're curious about how I figured that out. Look inside the python.py, the following code determines that very path('C:/Users/enoch/Downloads/WPy64-3741/python-3.7.4.amd64/Scripts/python.exe') which is displayed in the error messages:

deffrom_windows_launcher(cls, launcher_entry, name=None, company=None):
        ...
        default_path = base_path / "python.exe"ifnot default_path.exists():
            default_path = base_path / "Scripts" / "python.exe"

As you can see it looks for python.exe and in my case it was named as python2.exe.

Post a Comment for "Pipenv Failing To Install Packages"