Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
713 views
in Technique[技术] by (71.8m points)

macos - ImportError: cannot import name 'SourceDistribution' from 'pip._internal.distributions.source'

pip3 install is not working and also pip3 is not being able to downgrade to pip19 from pip20.0:

Rayaans-MacBook-Pro:~ rayaangrewal$ pip3 install 
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3", line 10, in <module>
        sys.exit(main())
      File "/Library/Frameworks/Python.framework/Versions/3.7/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 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
        module = importlib.import_module(module_path)
      File "/Library/Frameworks/Python.framework/Versions/3.7/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 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 24, in <module>
        from pip._internal.cli.req_command import RequirementCommand
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
        from pip._internal.operations.prepare import RequirementPreparer
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 16, in <module>
        from pip._internal.distributions import (
      File "/Library/Frameworks/Python.framework/Versions/3.7/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' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/distributions/source/__init__.py)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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. Get get-pip.py and run

python get-pip.py

or

python get-pip.py pip==19.3.1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...