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
558 views
in Technique[技术] by (71.8m points)

python - Pip 21.1 can't import InvalidSchemeCombination

At work, we use Github actions to build and test our Pull Requests before they can be approved. On Friday afternoon, everything was working just fine. On Monday morning, all tests were failing pretty early, with an error showing that pip could no longer find its own exceptions. Did something change with the newest Pip?

As you can see in the errors below, our own code isn't referenced, and I'm fairly certain nothing in our flow changed between Friday and Monday (we're a small team and the approved PRs don't have anything surprising there).

Error Traceback:

Traceback (most recent call last):
    File "/opt/hostedtoolcache/Python/3.7.9/x64/bin/pip", line 5, in <module>
      from pip._internal.cli.main import main
    File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 8, in <module>
      from pip._internal.cli.autocompletion import autocomplete
    File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
      from pip._internal.cli.main_parser import create_main_parser
    File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
      from pip._internal.cli import cmdoptions
    File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/cli/cmdoptions.py", line 22, in <module>
      from pip._internal.cli.progress_bars import BAR_TYPES
    File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/cli/progress_bars.py", line 9, in <module>
      from pip._internal.utils.logging import get_indentation
    File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/utils/logging.py", line 14, in <module>
      from pip._internal.utils.misc import ensure_dir
    File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/utils/misc.py", line 29, in <module>
      from pip._internal.locations import get_major_minor_version, site_packages, user_site
    File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
      from . import _distutils, _sysconfig
    File "/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/locations/_sysconfig.py", line 8, in <module>
      from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
  ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions' (/opt/hostedtoolcache/Python/3.7.9/x64/lib/python3.7/site-packages/pip/_internal/exceptions.py)
Error: The process '/opt/hostedtoolcache/Python/3.7.9/x64/bin/pip' failed with exit code 1
See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

For macOS X, this problem happened to me after I upgraded my homebrew, What really worked for me is this,

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

then

python get-pip.py

according to the discussion in the reference, it seems only pip version 21.1.1 fixed the problem.

Refer to the following discussion https://github.com/pypa/pip/issues/7217


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

...