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
Contents
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.
- First, run the following command:
python -m ensurepip --default-pip
- Get the get-pip.py script from https://bootstrap.pypa.io/get-pip.py
- 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
- 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