Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downgrade and upgrade: cannot import name 'SourceDistribution' #8160

Closed
hugovk opened this issue Apr 28, 2020 · 6 comments
Closed

Downgrade and upgrade: cannot import name 'SourceDistribution' #8160

hugovk opened this issue Apr 28, 2020 · 6 comments
Labels
kind: crash For situations where pip crashes type: maintenance Related to Development and Maintenance Processes

Comments

@hugovk
Copy link
Contributor

hugovk commented Apr 28, 2020

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)
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Apr 28, 2020
@pradyunsg
Copy link
Member

That's a known issue with pip 20.0 (which was a broken release) -- see #7620.

@hugovk
Copy link
Contributor Author

hugovk commented Apr 28, 2020

Good to hear, I guess this can be closed then :)

I just picked 20 out of the air because I wanted to downgrade from my local dev install, and upgrade to the new release.

@pradyunsg
Copy link
Member

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

@pradyunsg
Copy link
Member

Thanks @hugovk for the detailed bug report that made it easy to identify why this was happening! With 20.0 yanked, I think I can go ahead and close this now. :)

@pradyunsg pradyunsg added the type: maintenance Related to Development and Maintenance Processes label Apr 28, 2020
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Apr 28, 2020
@pradyunsg pradyunsg added kind: crash For situations where pip crashes S: needs triage Issues/PRs that need to be triaged labels Apr 28, 2020
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Apr 28, 2020
@hugovk
Copy link
Contributor Author

hugovk commented Apr 28, 2020

You're welcome, and thanks!

Reason for being yanked: <none given>

Can you provide a reason at PyPI?

Perhaps something along the lines of "20.0 is a broken build, use >=20.1 instead"?

$ python3.6 -m 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.*))
Reason for being yanked: <none given>
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

@pradyunsg
Copy link
Member

Can you provide a reason at PyPI?

Nope. :(

pypi/warehouse#7856

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind: crash For situations where pip crashes type: maintenance Related to Development and Maintenance Processes
Projects
None yet
Development

No branches or pull requests

2 participants