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
For Windows users, this problem happened to me after I upgraded to pip v21.2.4, What really worked for me is this,
So, I deleted my older v of pip, and reinstall using CMD Go through these steps to delete those older versions :
C:\Users\Win\anaconda3\Scripts
or old installation of python38 some way you can applypip3,pip3.8,pip3-script or pip-script delete those files.ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions'
The reason behind this error is that the pip file is corrupted.
The 100% solution is as simple as follows:
python -m ensurepip --default-pippython get-pip.pycurl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python get-pip.py
This issue was encountered after updating Conda via conda update anaconda
Issue seems to be related to pip v21.2.4
As Mahmood G. B. indicated above:
python -m ensurepip --default-pipget-pip.py then save file to local directoryterminal/command prompt (Admin privileges), cd to the folder
containing the downloaded get-pip.py file and run: python get-pip.py"WARNING: You are using pip version 21.0; however, version 21.3.1 is available.
You should consider upgrading via the python -m pip install --upgrade pip command"
I was facing the same issue on linux. Here is the solution for debian or similar versions:
First download the get-pip.py with:
wget https://bootstrap.pypa.io/get-pip.py
Or go to the url and copy all the contents to a new .py file on your system. You can name it whatever you but make sure to use same file name in the next step.
And then install a specific version of pip (execute in the same directory as the get-pip.py file):
python get-pip.py pip==21.0.1 #or any other version
pip command was not working at all
For windows 10 this worked for me :-
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
after this
python get-pip.py
Yes, there has been a release and the last commit modifying that file is from 2 days ago, however most likely it'll be something older.
Citing from the NEWS.rst it looks like there's some migration in progress:
Process
-------
- Start installation scheme migration from ``distutils`` to ``sysconfig``. A
warning is implemented to detect differences between the two implementations to
encourage user reports, so we can avoid breakages before they happen.
However, it'd be for the best to submit a bug so they can release a fix if necessary.
Classic workaround, downgrade to 21.0.1 i.e. the next latest version after 21.1:
pip install pip==21.0.1
Update:
Linking the issue #9880 submitted by OP.
Update 2:
Adjusting according to the OP's issue and another person's experience in the linked issue.
Don't use -I flag for pip install, it's for installing over the files (hence pip install --ignore-installed) you have present on your system instead of the real upgrading (installing a new version, then removing the old one).
Instead, use -U (i.e. pip install --upgrade) flag which will do what you want.
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
pip install pip==21.0.1 did not work for my case. Running this command still raise to the same error.
You need to save get-pip.py file in the anaconda3\Scripts directory or anaconda3\envs\[env_name]\Scripts if you are working on virtual environment. Then, you need to cd to this directory:
cd anaconda3\Scripts
After that run:
python get-pip.py pip==19.3.1
or
python get-pip.py pip==21.0.1