Skip to content
Home » ImportError: cannot import name ‘InvalidSchemeCombination’ from ‘pip._internal.exceptions’

ImportError: cannot import name ‘InvalidSchemeCombination’ from ‘pip._internal.exceptions’

To solve ImportError: cannot import name ‘InvalidSchemeCombination’ from ‘pip._internal.exceptions’ error follow below methods.

ERROR LOG

File "/opt/abc/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

How to solve ImportError: cannot import name ‘InvalidSchemeCombination’ from ‘pip._internal.exceptions’ ?

This issue ImportError: cannot import name ‘InvalidSchemeCombination’ from ‘pip._internal.exceptions’ occured dur to the pip file is corrupted, which is the cause of this issue.

  1. First, run the following command: python -m ensurepip --default-pip
  2. Get the get-pip.py script from https://bootstrap.pypa.io/get-pip.py
  3. Open a terminal/command line with administrative access, navigate to the folder containing the downloaded get-pip.py file, and run: python get-pip.py
  4. The issue has been resolved.

Alternative to Solve ImportError: cannot import name ‘InvalidSchemeCombination’ from ‘pip._internal.exceptions’

This problem occurred for me on macOS X after I upgraded my homebrew. This is what really worked for me:

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 appears that only pip version 21.1.1 fixed the problem.

sample code

Hope the above solution works.

Also read :

CUDA initialization: Unexpected error from cudaGetDeviceCount()
Could not load dynamic library ‘cudnn64_8.dll’; dlerror: cudnn64_8.dll not found