Pip: Unable to install anything using pip after upgrade to 20.0

Created on 21 Jan 2020  ·  94Comments  ·  Source: pypa/pip

Environment

  • pip version: 20.0
  • Python version: 3.6.8
  • OS: Ubuntu 14.04.6 (Don't judge)

Description

During our build process, we automatically upgrade to the newest version on pip. After upgrading to 20.0 (using pip install -U pip setuptools), we are unable to install any packages.

Output

Traceback (most recent call last):
  File "/home/svc-web/webshop/env/bin/pip", line 8, in <module>
    sys.exit(main())
  File "/home/svc-web/webshop/env/lib/python3.6/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/home/svc-web/webshop/env/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/svc-web/webshop/env/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand
  File "/home/svc-web/webshop/env/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "/home/svc-web/webshop/env/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
    from pip._internal.distributions import (
  File "/home/svc-web/webshop/env/lib/python3.6/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
    from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution'

Most helpful comment

It's worth mentioning that mistakes, problems and unforeseen mishaps happen to all projects, no matter how much you plan and try to mitigate such events.

Spare a thought and supportive comments for the volunteer Pythonistas looking into this and fixing it for all our benefit.

All 94 comments

I see the same thing:

$ pip install requests
Traceback (most recent call last):
  File "/home/ntoll/.virtualenvs/sdclient/bin/pip", line 8, in <module>
    sys.exit(main())
  File "/home/ntoll/.virtualenvs/sdclient/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/home/ntoll/.virtualenvs/sdclient/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/home/ntoll/.virtualenvs/sdclient/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/ntoll/.virtualenvs/sdclient/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand
  File "/home/ntoll/.virtualenvs/sdclient/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "/home/ntoll/.virtualenvs/sdclient/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
    from pip._internal.distributions import (
  File "/home/ntoll/.virtualenvs/sdclient/lib/python3.7/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
    from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (/home/ntoll/.virtualenvs/sdclient/lib/python3.7/site-packages/pip/_internal/distributions/source/__init__.py)

Python 3.7.2 on Ubuntu 18.04

Same here https://github.com/pypa/pip/pull/7619#issuecomment-576649700

Seems like unclean dist.

Exactly the same with Python 3.7.5 on Fedora 29. The same happens both in virtualenvs and with --user. Also, doesn't matter if I run pip3.7 or python3.7 -m pip.

And as @ntoll suggests below, kudos for everyone working to fix this unfortunate glitch! Nice to see only neutral and supportive comments here. Open Source community at its best.

same here, python 3.8.1 on android 9 termux. i assume it's the same for basically everyone

I have the same issue in a docker build, using the python:3.8-busterimage:

Step 1/6 : FROM python:3.8-buster
 ---> 0a3a95c81a2b
Step 2/6 : ADD . /app
 ---> a3be40376bd8
Step 3/6 : WORKDIR /app
 ---> Running in 6f53960d3257
Removing intermediate container 6f53960d3257
 ---> 14b7a3ccf004
Step 4/6 : RUN pip install --upgrade pip setuptools
 ---> Running in 6f9dfc84e0a3
Collecting pip
  Downloading https://files.pythonhosted.org/packages/60/65/16487a7c4e0f95bb3fc89c2e377be331fd496b7a9b08fd3077de7f3ae2cf/pip-20.0-py2.py3-none-any.whl (1.5MB)
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/a7/c5/6c1acea1b4ea88b86b03280f3fde1efa04fefecd4e7d2af13e602661cde4/setuptools-45.1.0-py3-none-any.whl (583kB)
Installing collected packages: pip, setuptools
  Found existing installation: pip 19.3.1
    Uninstalling pip-19.3.1:
      Successfully uninstalled pip-19.3.1
  Found existing installation: setuptools 41.6.0
    Uninstalling setuptools-41.6.0:
      Successfully uninstalled setuptools-41.6.0
Successfully installed pip-20.0 setuptools-45.1.0
Removing intermediate container 6f9dfc84e0a3
 ---> 4db4dd1c01a1
Step 5/6 : RUN pip install -r requirements.txt
 ---> Running in 01e0b70d0d81
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
    from pip._internal.distributions import (
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
    from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (/usr/local/lib/python3.8/site-packages/pip/_internal/distributions/source/__init__.py)

Same here. Python 3.7.4 using Ubuntu 18.04 and Alpine linux on Docker.

Same on MacPorts Python on macOS:

$ rm -rf venv && python3.8 -m venv venv && ./venv/bin/python -m pip install -U pip && ./venv/bin/python -m pip install requests
Collecting pip
  Using cached https://files.pythonhosted.org/packages/60/65/16487a7c4e0f95bb3fc89c2e377be331fd496b7a9b08fd3077de7f3ae2cf/pip-20.0-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-20.0
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  ...
  File "/Users/messa/test/venv/lib/python3.8/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
    from pip._internal.distributions import (
  File "/Users/messa/test/venv/lib/python3.8/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
    from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (/Users/messa/test/venv/lib/python3.8/site-packages/pip/_internal/distributions/source/__init__.py)

Exact same issue. Python 3.7.6, system: Mac OS Catalina

Same issue on Python 3.7.3 which is the Ubuntu 19.04 default.

It's worth mentioning that mistakes, problems and unforeseen mishaps happen to all projects, no matter how much you plan and try to mitigate such events.

Spare a thought and supportive comments for the volunteer Pythonistas looking into this and fixing it for all our benefit.

Note a maintainer of pip, but I guess we have two options to move forward: 1) cut off a clean dist and bump the version; 2) at least pull off 20 from pypi (might be too late already).

In the meanwhile this can be helpful if you use virtualenv:

virtualenv venv --no-pip
source venv/bin/activate
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py pip==19.3.1

Just wanted to chime in that our build system went down with this too. Luckily its not critical, and I agree with @ntoll that sometimes things goes south, and I'm sure you're doing all you can to fix this.

@pradyunsg I confirm the issue. I suggest pulling it from PyPI.

@xdralex Yes :+1: I was just typing something similar.

Plus, if you've got a usable pip in your global env, then virtualenv venv --no-download will use that one instead of downloading the broken version.

Only for completeness: Windows is also affected. Win10 + Python 3.7.4 here (WinPython):

python -m pip uninstall pip Traceback (most recent call last): File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\site-packages\pip\__main__.py", line 19, in <module> sys.exit(_main()) File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\site-packages\pip\_internal\cli\main.py", line 73, in main command = create_command(cmd_name, isolated=("--isolated" in cmd_args)) File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\site-packages\pip\_internal\commands\__init__.py", line 96, in create_command module = importlib.import_module(module_path) File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\site-packages\pip\_internal\commands\uninstall.py", line 9, in <module> from pip._internal.cli.req_command import SessionCommandMixin File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\site-packages\pip\_internal\cli\req_command.py", line 20, in <module> from pip._internal.operations.prepare import RequirementPreparer File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\site-packages\pip\_internal\operations\prepare.py", line 16, in <module> from pip._internal.distributions import ( File "v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\site-packages\pip\_internal\distributions\__init__.py", line 1, in <module> from pip._internal.distributions.source import SourceDistribution ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source' (v:\bin\scripting\python\3.7.4\python-3.7.4.amd64\lib\site-packages\pip\_internal\distributions\source\__init__.py)

Seemingly affects any pipor python -m pip commands after installing 20.0. So, I'm also unable to revert to 19.3.

edit: This workaround helped.

For those people here with broken build processes because they do something similar to OP's pip install -U pip setuptools - remember you can tweak this to ban or constrain any particular version.

Both of these seem to work OK for me locally:

$ pip install -U "pip<20" setuptools
$ pip install -U "pip!=20.0" setuptools

pip will warn you about not being on the latest version, but won't install v20.0.

@james-gonzalez Not sure cutting off a new release is part of CI.

Reading https://pip.pypa.io/en/latest/development/release-process/#creating-a-new-release, maybe after checking out master a git clean should be applied.

I have the exact same issue in a clean docker container running latest Ubuntu as well as an up-to-date Arch Linux.

I tried to download and run get-pip in a new virtualenv but it not works still :/
Ive noted that in pip/_internal/distributions/ folder have a python file called source.py and a folder called source. Just for now I manually removed the folder and pip is running again

A workaround to get pip working again is getting the get-pip.py script and running:
python get-pip.py pip==19.3.1
This will revert pip to the previous version

Do you not listen to your own CI tests?

Always remember that the maintainers are also humans, and programming mistakes are actually common among this species. We should be providing any support they or the community need than blaming people.

I've just ran into the same problem and I installed pip from the repo (20.1.dev) and it solved it. Just cloned this repo and pip install -e ./pip

Btw, looks like it's just an missing import. My fix was:

pip\_internal\distributions\source\__init__.py

from .legacy import SourceDistribution

Confirmed, our CI system is seeing the same issue.

https://github.com/pypa/pip/issues/7217
Install an older version:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py pip==19.3.1

A possible local workaround:
https://github.com/pypa/pip/issues/7217#issuecomment-576653463

Removing folder ./site-packages/pip/_internal/distributions/source helps!

This is being fixed in https://github.com/pypa/pip/pull/7621, as linked from https://github.com/pypa/pip/issues/7217 :)

Same, confirmed on both Amazon Linux on an EC2 instance as well as a local Fedora machine.

Out of sheer curiosity, why was this version released even though the last pipelines failed showing this error? https://travis-ci.org/pypa/pip/builds/639902383

Not a cutting remark at all, just interested in the release process and how can this kind of issues can be avoided in the future!

Many thanks for the ongoing work to fix it :+1:

I had recently upgraded to pip 20.0 using "python -m pip install --upgrade pip". Following the upgrade, even "pip list" command broke. Now I see a new version 20.0.1 is released, but if I do "python -m pip install --upgrade pip" then I get the same error. How can I upgrade to latest pip version 20.0.1?

@nachiketrss try install with get-pip.py

@nachiketrss curl https://bootstrap.pypa.io/get-pip.py | python

Or python3

Comparable error for CentOS 7 with Python3.6:

$ cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

$ mkvirtualenv --python=/usr/bin/python3.6 foo

(foo) $ which python
~/.virtualenvs/foo/bin/python


(foo) $ which pip
~/.virtualenvs/foo/bin/pip

(foo) $ pip --version
pip 20.0 from /home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip (python 3.6)


(foo) $ pip list
Traceback (most recent call last):
  File "/home/foo/.virtualenvs/foo/bin/pip", line 10, in <module>
    sys.exit(main())
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/home/foo/.virtualenvs/foo/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 13, in <module>
    from pip._internal.cli.req_command import IndexGroupCommand
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
    from pip._internal.distributions import (
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
    from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution'

No longer seeing issue with pip 20.0.1 release, thanks. Agree, it would be helpful to understand job failures above in build logs @lerela referenced.

I can confirm 20.0.1 fixed the issue.

Comparable error for CentOS 7 with Python3.6:

$ cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)

$ mkvirtualenv --python=/usr/bin/python3.6 foo

(foo) $ which python
~/.virtualenvs/foo/bin/python


(foo) $ which pip
~/.virtualenvs/foo/bin/pip

(foo) $ pip --version
pip 20.0 from /home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip (python 3.6)


(foo) $ pip list
Traceback (most recent call last):
  File "/home/foo/.virtualenvs/foo/bin/pip", line 10, in <module>
    sys.exit(main())
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/cli/main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/home/foo/.virtualenvs/foo/lib64/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/commands/list.py", line 13, in <module>
    from pip._internal.cli.req_command import IndexGroupCommand
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
    from pip._internal.distributions import (
  File "/home/foo/.virtualenvs/foo/lib/python3.6/site-packages/pip/_internal/distributions/__init__.py", line 1, in <module>
    from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name 'SourceDistribution'

Closing the current terminal and working with a new one solved the issue for me.

Alrighty, looks like this has been fixed. Closing.

I know that all the people working on this are volunteers and I am really glad for all the work they do!

But as @lerela mentioned we should investigate a bit how such thing could happen and how can we avoid such mistake.

Pip is one of the core and most used tools in the whole software industry.
And it looks like that a new version was released even though it was not at least tested to run basic commands.

Do we check these builds before release?
Is a release process somehow managed and reviewed or is it a one-man show?

I would understand this situation if such mistake happens in some urgent hurried hotfix release, but version 20 was released several months after 19.3.1.

Well, we figured out what caused this and are making the release process changes to fix that: https://github.com/pypa/pip/pull/7624

Out of sheer curiosity, why was this version released even though the last pipelines failed showing this error? https://travis-ci.org/pypa/pip/builds/639902383

Not a cutting remark at all, just interested in the release process and how can this kind of issues can be avoided in the future!

Many thanks for the ongoing work to fix it 👍

@lerela @pabelanger that's not what happened here: that build log is was run after the release was done (that commit was run during release by a script) as evidenced by those failed build logs (for example this one):

Using cached https://files.pythonhosted.org/packages/60/65/16487a7c4e0f95bb3fc89c2e377be331fd496b7a9b08fd3077de7f3ae2cf/pip-20.0-py2.py3-none-any.whl

That this would be the case makes sense: this change was merged some time ago and did not immediately cause failures because it is not a source code bug, an sich. For example, it does not occur when upgrading from an 'old enough' pip (9.0.1 is what I used). It is instead caused by artefacts being left behind when upgrading (the underlying bug of which is unclear at this time, at least to me).

This issue was not caught by the pipeline, and so further improvements to test upgrade paths in the pipeline there would be welcome @lerela @pabelanger and contributing to pip is easy!

Confirmed, AWS Beanstalk fails when you try to install or upgrade a new based python app ...

Thank you for fixing the issue so fast @pradyunsg .

What's the best path forward on fixing this? Attempting to update pip on my ec2 instance from pip20.0 to 20.1 still fails with this error. sudo pip2 install -U pip2.

What's the best path forward on fixing this? Attempting to update pip on my ec2 instance from pip20.0 to 20.1 still fails with this error. sudo pip2 install -U pip2.

https://github.com/pypa/pip/issues/7620#issuecomment-576669697

@fideloper Thanks for asking! I answered this on a different issue just now: https://github.com/pypa/pip/issues/7217#issuecomment-576698030

@honnix's suggestion also works, although I would recommend against using curl ... | python.

Great, thank you all very much!

@fideloper also if your distro doesn't rip off ensurepip from CPython, you should be able to use it via python -m ensurepip

Also, thanks for posting your analysis of the CI runs @cryvate! I just came back to respond to that, and your comment is basically on point.

FWIW, the only CI job for pip that was failing before pip 20.0 was a non-test job for Windows because of some git+Windows+authors.txt issue, which is mostly unrelated to the actual release process.

Looks fixed to me. I got this error this morning on one of our CI pipelines and now it seems fixed. Pinning pip install -U "pip<20" worked as a workaround, but i accidentally tried it without it just now and it seems to be fixed.

We're still seeing this issue with 20.0.1.

Will work on putting together a repro, but the error we're getting is because of a dependency on xgboost==0.81 which on pip 19 downloaded a whl package, but on 20.0 and 20.0.1 downloads a tarball and tries to build it (which fails because our build chain does not have the required tooling installed).

@tomasaschan Could you file a new issue, with a bit more detail about how the build happens and, ideally, with a minimal reproducer?

@tomasaschan I think you're seeing a different issue, not this. This issue is about a broken installation of pip itself. In your case, I think you're seeing some of the behaviour changes around wheel tags such as #6908. Could you file a new issue please?

(xgboost has some odd tags. It has xgboost-0.90-py2.py3-none-manylinux1_x86_64.whl but that's very odd: if a package contains compiled C extensions as indicated by manylinux1, it's perhaps unlikely to really be py2.py3-none, but that can be discussed. Contrast with gevent-1.4.0-cp27-cp27m-manylinux1_x86_64.whl)

sudo python get-pip.py pip==19.3.1
for fix this issue

@pradyunsg @jamadden Working on putting together a minimal Dockerfile that reproduces the error; will file a new issue once I manage to. (We have several layers of internal base images I have to dig through to find something to put in FROM that's publicly available...)

For the benefit of Py noobs such as myself, can someone provide a clean, complete fix or workaround for this issue? Also, not sure how significant this is, but the error message I got is a bit different:
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/usr/lib/python3.8/site-packages/pip/_internal/index/__init__.py)
Thanks for the quick fix, and also for the write-up!

@richard-steiger I had the same issue. My fix was to uninstall pip, download the tar.gz of v20.0.1 from pypi, then install by running "python setup.py install".

Fixed (under Cygwin-X) !

blh@LPT-V-23 ~
$ python /cygdrive/c/Temp/get-pip.py pip==19.3.1
Collecting pip==19.3.1
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
100% |################################| 1.4MB 585kB/s
Installing collected packages: pip
Found existing installation: pip 20.0
Uninstalling pip-20.0:
Successfully uninstalled pip-20.0
Successfully installed pip-19.3.1
You are using pip version 19.3.1, however version 20.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

blh@LPT-V-23 ~
$ pip-review --local --interactive
pexpect==4.8.0 is available (you have 4.7.0)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit y
pip==20.0.1 is available (you have 19.3.1)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit n
urllib3==1.25.8 is available (you have 1.25.7)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit y
Collecting pexpect==4.8.0
Downloading https://files.pythonhosted.org/packages/39/7b/88dbb785881c28a102619d46423cb853b46dbccc70d3ac362d99773a78ce/pexpect-4.8.0-py2.py3-none-any.whl (59kB)
|################################| 61kB 797kB/s
Collecting urllib3==1.25.8
Downloading https://files.pythonhosted.org/packages/e8/74/6e4f91745020f967d09332bb2b8b9b10090957334692eb88ea4afe91b77f/urllib3-1.25.8-py2.py3-none-any.whl (125kB)
|################################| 133kB 14.6MB/s
Requirement already satisfied: ptyprocess>=0.5 in /usr/lib/python3.6/site-packages (from pexpect==4.8.0) (0.6.0)
Installing collected packages: pexpect, urllib3
Found existing installation: pexpect 4.7.0
Uninstalling pexpect-4.7.0:
Successfully uninstalled pexpect-4.7.0
Found existing installation: urllib3 1.25.7
Uninstalling urllib3-1.25.7:
Successfully uninstalled urllib3-1.25.7
Successfully installed pexpect-4.8.0 urllib3-1.25.8
WARNING: You are using pip version 19.3.1; however, version 20.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

blh@LPT-V-23 ~
$ pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/57/36/67f809c135c17ec9b8276466cc57f35b98c240f55c780689ea29fa32f512/pip-20.0.1-py2.py3-none-any.whl (1.5MB)
|################################| 1.5MB 2.4MB/s
Installing collected packages: pip
Found existing installation: pip 19.3.1
Uninstalling pip-19.3.1:
Successfully uninstalled pip-19.3.1
Successfully installed pip-20.0.1

Now pip is fully working in version 20.0.1 !!!

blh@LPT-V-23 ~
$ pip-review --local --interactive
dbus-python==1.2.16 is available (you have 1.2.8)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit n
numpy==1.18.1 is available (you have 1.16.2)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit n

readthedocs is also affected by this:

/home/docs/checkouts/readthedocs.org/user_builds/returns/envs/latest/bin/python -m pip install --upgrade --cache-dir /home/docs/checkouts/readthedocs.org/user_builds/returns/.cache/pip pip

Traceback (most recent call last):
  File "/home/docs/.pyenv/versions/3.6.8/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/docs/.pyenv/versions/3.6.8/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/docs/checkouts/readthedocs.org/user_builds/returns/envs/latest/lib/python3.6/site-packages/pip/__main__.py", line 16, in <module>
    from pip._internal import main as _main  # isort:skip # noqa
  File "/home/docs/checkouts/readthedocs.org/user_builds/returns/envs/latest/lib/python3.6/site-packages/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/docs/checkouts/readthedocs.org/user_builds/returns/envs/latest/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/docs/checkouts/readthedocs.org/user_builds/returns/envs/latest/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
    from pip._internal.commands import (
  File "/home/docs/checkouts/readthedocs.org/user_builds/returns/envs/latest/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "/home/docs/checkouts/readthedocs.org/user_builds/returns/envs/latest/lib/python3.6/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "/home/docs/checkouts/readthedocs.org/user_builds/returns/envs/latest/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 25, in <module>
    from pip._internal.index import PackageFinder
ImportError: cannot import name 'PackageFinder'

readthedocs just installed pip 20.0.1 for me, so the cascade of breakage seems halted, good job! :smiley:

pip 20.0.1 doesn't fix it for me on MACOS 10.15.2 with Python 2.7. Problem also existed with pip 19.3.1, which I tried first.

iMac:~ george$ sudo easy_install pip Searching for pip Best match: pip 20.0.1 Processing pip-20.0.1-py2.7.egg Removing pip 19.3.1 from easy-install.pth file Adding pip 20.0.1 to easy-install.pth file Installing pip script to /usr/local/bin Installing pip3.8 script to /usr/local/bin Installing pip3 script to /usr/local/bin

Using /Library/Python/2.7/site-packages/pip-20.0.1-py2.7.egg Processing dependencies for pip Finished processing dependencies for pip

iMac:~ george$ pip install -U spacy Traceback (most recent call last):
File "/opt/local/bin/pip", line 11, in
sys.exit(main())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 24, in
from pip._internal.cli.req_command import RequirementCommand
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 20, in
from pip._internal.operations.prepare import RequirementPreparer
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 16, in
from pip._internal.distributions import (
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_internal/distributions/__init__.py", line 1, in
from pip._internal.distributions.source import SourceDistribution
ImportError: cannot import name SourceDistribution

@george542 you have a different pip installed normally while you also installed the newer pip in a broken way with setuptools, please clean out all pip installs and pip egg installs, then install pip using the get-pip script which deals a correct setup

Had this issue when trying to install awscli via pip in circleci.

resolved by preforming pip install pip -U prior to running pip install awscli in the _config.yml_ file.

readthedocs just installed pip 20.0.1 for me, so the cascade of breakage seems halted, good job! 😃

How did you get readthedocs to install pip 20.0.1 for you? I tried specifying pip==20.0.1 in my requirements.txt file, but am still getting the error mentioned above by sobolevn.

Hmm, it just updates pip at the start by default for me. But I think wiping the build environment could trigger it.

So a pip2.7 install --upgrade pip should now resolve the issue?

Hmm, it just updates pip at the start by default for me. But I think wiping the build environment could trigger it.

That worked! Thank you!

Hello to all,
My operating system is Arch-Linux.
I followed the documentation to install wfuzz, unfortunately I get this error again. How could I solve it? Thank you in advance.

sudo pip install wfuzz Traceback (most recent call last): File "/usr/bin/pip", line 11, in <module> load_entry_point('pip==19.3', 'console_scripts', 'pip')() File "/usr/lib/python3.8/site-packages/pip/_internal/main.py", line 45, in main command = create_command(cmd_name, isolated=("--isolated" in cmd_args)) File "/usr/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command module = importlib.import_module(module_path) File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 24, in <module> from pip._internal.cli.req_command import RequirementCommand File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 17, in <module> from pip._internal.index import PackageFinder ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/usr/lib/python3.8/site-packages/pip/_internal/index/__init__.py)

@Serialc0de See https://github.com/pypa/pip/issues/5599. Your /usr/bin/pip and your pip installation are out of sync. (And you shouldn't be using sudo pip...

@ Serialc0de Vedi # 5599 . La tua /usr/bin/pipe la tua installazione pip non sono sincronizzate. (E non dovresti usare sudo pip...

Could you help me please, I have been banging my head for 19 hours but I can't find anyone to solve the problem, not even the freelancer professionals, can you help me through tw so you can explain me well? Thanks in advance brò

A workaround to get pip working again is getting the get-pip.py script and running:
python get-pip.py pip==19.3.1
This will revert pip to the previous version

Thanks! this worked for me (python 3.7.4 running on cygwin64)

Just a heads up, we also ran into other issues with this, which we've fixed here:

https://github.com/readthedocs/readthedocs.org/pull/6598#issue-368291092

Just a heads up, we also ran into other issues with this, which we've fixed here:

readthedocs/readthedocs.org#6598 (comment)

Thanks. Simply running python get-pip.py fixed the problem for me (installed pip-20.0.2).

Got latest 20.0.2 but still seeing same behavior pip is not working at all

Same as @abhi2687. I have a feeling it may be Ubuntu running the wrong version (aka: https://github.com/pypa/pip/issues/7620#issuecomment-579257985) . At the moment, the failing script is:

pip install --upgrade pip
pip install -r requirements.txt --user
pip install -r requirements_dev.txt --user

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/main.py", line 45, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 23, in <module>
    from pip._internal.cli.req_command import RequirementCommand
  File "/usr/local/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 17, in <module>
    from pip._internal.index import PackageFinder
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/usr/local/lib/python3.8/site-packages/pip/_internal/index/__init__.py)

Exited with code exit status 1

the upgrade seems fine and it does download/install 20.0.2, but then it seems to run 20.0.

I am using a Circleci box to verify. On my local machine, pip install --upgrade pip fixed the issue (Ubuntu 19.10). So not sure if its certain versions of Ubuntu, something to do with the circleci container circleci/python:3.8 or what.

So far the two solutions that have worked:

  1. Downgrade to python get-pip.py pip==19.3.1 and wait for this to blow over.
  2. Upgrade to 20.0.2 via pip install --upgrade pip and remove all references to 20.0.0.

Nothing didn't work for me also!
Tried on Windows 7 & 10 & Linux Raspbian, but nothing seems to work!
I have the latest 20.0.2 pip installed and Python 3.8.1.

Python 3.8.1 installed, Windows 8.1 same error: Warning: You are using pip version 19.2.3, however version 20.0.2 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.

A workaround to get pip working again is getting the get-pip.pyhttps://bootstrap.pypa.io/get-pip.py script and running:
python get-pip.py pip==19.3.1
This will revert pip to the previous version

Thanks! this worked for me (python 3.7.4 running on cygwin64)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/pypa/pip/issues/7620?email_source=notifications&email_token=ABHAYIUZZTOF5FQIJBXBHJDRACAGRA5CNFSM4KJSF7MKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKERQ6I#issuecomment-579410041, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABHAYIVCAZKVV53U4GXSTBTRACAGRANCNFSM4KJSF7MA.

[R Steiger] Thanks, also worked with python3.8.1

Well!
I did that but at that time there was an SSL issue with PyPI

I've been getting the same issue for the last couple of weeks. I'm running MacOS 10.5.3 and I've installed Python 3.7.6 via Homebrew. I just upgraded Pip on one of my virtual environments today from version 19.x to version 20.0 and it has broken my virtual environment. I'm getting the following error:

Traceback (most recent call last): File "/Users/jeff/Envs/test/bin/pip3", line 5, in <module> from pip._internal.cli.main import main ModuleNotFoundError: No module named 'pip._internal.cli.main'

For anyone having this in their CI try clearing your CI cache

It might be the same problem as here. Try using

pip install --no-use-pep517 <package>

Probably related https://github.com/pypa/pipenv/issues/4128. Another fix I found working for me is

pip install -U pipenv virtualenv
virtualenv .venv --seeder pip
PIPENV_VENV_IN_PROJECT=1 pipenv install

@jeffself same situation here.

https://github.com/pypa/pip/issues/5599#issue-341052110 solves the problem (as indicated by the pip message).

A workaround to get pip working again is getting the get-pip.py script and running:
python get-pip.py pip==19.3.1
This will revert pip to the previous version

Thanks bro... this workaround saves my archlinux distro =)

I would suggest a common workground that save lots of Time and Pain:
Open the Setup.cfg and the Pip module and validate your pip version,module name+version etc... many times after upgrade/downgrade the file status doesn't change, so as the Requirements which lead to conflicts.

Now that PyPI has support for yanked releases, I've gone ahead and marked pip 20.0 as "yanked". pip > 19.2 would not install it by default and would print a warning, when installing it via pip install pip==20:

WARNING: The candidate selected for download or install is a yanked version: 'pip' candidate (version 20.0 at https://files.pythonhosted.org/packages/60/65/16487a7c4e0f95bb3fc89c2e377be331fd496b7a9b08fd3077de7f3ae2cf/pip-20.0-py2.py3-none-any.whl#sha256=eea07b449d969dbc8c062c157852cf8ed2ad1b8b5ac965a6b819e62929e41703 (from https://pypi.org/simple/pip/) (requires-python:>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*))

i am having issue with installing packages using pip , even though i have installed python using anaconda still i am facing the issue, i tried uninstalling it and then again installing it back to check whether the issue was solved or not , but the error still remained.

Here is the screenshot of the error i have been facing , please help me sort out this error.
Thanking you in Advance
image

basically i am getting an error if i use pip , what do i need to do

@AvAkanksh As I saw it's kinda uncertain this error, have you tried to fully remove Python from your computer?

@AvAkanksh As I saw it's kinda uncertain this error, have you tried to fully remove Python from your computer?

Ya I have tried even that but there was so change in the output , it still gave me the same error

@AvAkanksh, using Google I found these probably much better places to look for hints to solve your specific issue:

If you find a solution, a most helpful thing to do would be to link to it in comments of all the above pages.

Good luck, hope you find the solution!

The same...😡

I have the same error...

Searching for pip
Best match: pip 20.2.2
Adding pip 20.2.2 to easy-install.pth file
Installing pip script to /usr/local/bin
error: [Errno 2] No such file or directory: '/usr/local/bin/pip'

Was this page helpful?
0 / 5 - 0 ratings