Python Pip broken with sys.stderr.write(f"ERROR: {exc}")

Solution 1:

You can get an older version (2.7) of get-pip.py

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

In my opinion, you should create a python2 virtualenv and install your python2 package in it, as well as pip2. For example, when I installed cuckoo sandbox, I did it like this:

virtualenv --python=python2 cuckoo/   # make your virtualenv folder with python2
cd cuckoo
source bin/activate
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py   # get pip for python2
python2 get-pip.py        # install pip in your virtualenv
pip install cuckoo       # install your python2 package

Hope it will help.

Solution 2:

This problem has to do with the fact that Python 2.7 reached end of its life and that the PIP community dropped support for it this month.

PIP displays deprecation notices such as

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.

To fix this and continue with unsupported Python 2.7 you should not upgrade to the latest pip version but to a version < 21.

pip install --upgrade "pip < 21.0"

Solution 3:

As PIP dropped support for Python 2.7 in result we are facing the above mentioned issue, following are the commands which actually worked for me on Ubuntu.

sudo apt-get remove --purge python-pip
sudo apt-get autoremove
sudo rm -f /usr/local/bin/pip
sudo easy_install pip==20.3.4
pip --version

Output: pip 20.3.4

Same can be achieved for CentOS by changing package manager name.

Solution 4:

Update: Please use following command to install the pip on python2.7

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

Enjoy it!

Solution 5:

This helped me (Ubuntu 16.04)

In general I removed completely pip and pip3 like:

whereis pip
sudo rm -f <results from whereis pip
whereis pip3
sudo rm -f <results from whereis pip3

Search pip and remove files and directories. In my case it was:

sudo rm -fr ~/.local/bin/pip3.5
sudo rm -fr ~/.local/bin/pip3
sudo rm -fr ~/.local/lib/python3.5/site-packages/pip*
sudo rm -rf ~/.cache/pip/
sudo rm -rf  /usr/lib/python2.7/dist-packages/pip*
sudo rm -rf  /usr/lib/python3/dist-packages/pip*

Then I installed pip3 once again:

Python 3.5

wget https://bootstrap.pypa.io/pip/3.5/get-pip.py

Python 3.6

wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --ignore-installed