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.

Downgrade and upgrade: cannot import name 'SourceDistribution'

See original GitHub issue

Environment

  • pip version: 20.1
  • Python version: 3.6, 3.8
  • OS: Mojave

Description

Expected behavior

Upgrades smoothly after downgrade.

How to Reproduce

python3.6 --version
python3.6 -m pip --version
python3.6 -m pip install -U pip
python3.6 -m pip install pip==20
python3.6 -m pip --version

Output

⌂66% [hugo:/private/tmp] 130 % python3.6 --version
Python 3.6.10
⌂68% [hugo:/private/tmp] % python3.6 -m pip --version
pip 20.1 from /Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/site-packages/pip (python 3.6)
⌂62% [hugo:/private/tmp] % python3.6 -m pip install -U pip
Requirement already up-to-date: pip in /Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/site-packages (20.1)
[hugo:/private/tmp] 2s % python3.6 -m pip install pip==20
Collecting pip==20
  Using cached pip-20.0-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.1
    Uninstalling pip-20.1:
      Successfully uninstalled pip-20.1
Successfully installed pip-20.0
[hugo:/private/tmp] 10s % python3.6 -m pip --version
pip 20.0 from /Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/site-packages/pip (python 3.6)
[hugo:/private/tmp] % python3.6 -m pip install -U pip
Traceback (most recent call last):
  File "/Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/site-packages/pip/__main__.py", line 19, in <module>
    sys.exit(_main())
  File "/Users/hugo/.pyenv/versions/3.6.10/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 "/Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/Users/hugo/.pyenv/versions/3.6.10/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 "/Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 24, in <module>
    from pip._internal.cli.req_command import RequirementCommand
  File "/Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.operations.prepare import RequirementPreparer
  File "/Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
    from pip._internal.distributions import (
  File "/Users/hugo/.pyenv/versions/3.6.10/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'

Can recover with get-pip.py:

[hugo:/private/tmp] 1 % python3.6 get-pip.py
Collecting pip
  Using cached pip-20.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0
    Uninstalling pip-20.0:
      Successfully uninstalled pip-20.0
Successfully installed pip-20.1
⌂66% [hugo:/private/tmp] 13s % python3.6 -m pip --version
pip 20.1 from /Users/hugo/.pyenv/versions/3.6.10/lib/python3.6/site-packages/pip (python 3.6)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
pradyunsgcommented, Apr 28, 2020

Now that PyPI has support for yanked releases, I’ve gone ahead and marked pip 20.0 as “yanked”.

This results in installing it via pip install pip==20 printing a warning now:

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.*))

0reactions
pradyunsgcommented, Apr 28, 2020

Can you provide a reason at PyPI?

Nope. 😦

pypa/warehouse#7856

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: cannot import name 'SourceDistribution' from 'pip ...
This is a bug in pip 20.0; see https://github.com/pypa/pip/issues/7620. It's fixed in pip 20.0.1. Upgrade to 20.0.1+ or downgrade to 19.3.1.
Read more >
Macos – ImportError: cannot import name 'SourceDistribution' from ...
Macos – ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source'. importerrormacospippython-3.7.
Read more >
cannot import name SourceDistribution - Launchpad Bugs
https://6d9b97dc35f887a99105-3214406b4544fce2f9d807df6ea4fe3f.ssl.cf5.rackcdn.com/701994/1/gate/tripleo-ci-centos-7-standalone-upgrade-stein ...
Read more >
importerror: cannot import name 'sourcedistribution
PIP Cannot Import Name SourceDistribution Import Error Fix . pip 20.0 import source distribution error fixed. upgrade or downgrade pip from 20.0 version....
Read more >
cannot import name SerializationError' error after the change ...
# The error happens due to incorrect pip package version has upgraded during the CHG0109659. ... # Perform downgrade the related pip packages...
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