[solved] Python Pip broken with sys.stderr.write(f“ERROR: {exc}”)

Hello Guys How Are You All ? Hope You all are fine. Today I Have Faced Python Pip broken with sys.stderr.write(f“ERROR: {exc}”) In Python. Python Pip broken with sys.stderr.write So Here I am Explain to you all the possible solutions Here.

Without Wasting your time, Lets start This Article to Solve This Error in Anaconda.

How Python Pip broken with sys.stderr.write(f“ERROR: {exc}”) error ocuurs?

Python gives me error message like above, but I cannot solve it.

On fresh Vagrant VM using box bento/centos-7 the following commands corrupt my pip installation:

yum update
yum install epel-release -y
yum install python-pip -y
/usr/bin/pip2 install --upgrade pip setuptools pyOpenSSL psycopg2-binary lxml

This fails at the end with

  Downloading (2.1MB)
    100% |████████████████████████████████| 2.1MB 821kB/s
    Complete output from command python egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "setuptools/", line 16, in <module>
        import setuptools.version
      File "setuptools/", line 1, in <module>
        import pkg_resources
      File "pkg_resources/", line 1367
        raise SyntaxError(e) from e
    SyntaxError: invalid syntax

Command "python egg_info" failed with error code 1 in /tmp/pip-build-GZrC3W/setuptools/
You are using pip version 8.1.2, however version 21.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

If I then upgrade Pip I notice that my Python is broken. After that all pip commands end with SyntaxError

[[email protected] ~]# pip install --upgrade pip
Collecting pip
  Using cached
Installing collected packages: pip
  Found existing installation: pip 8.1.2
    Uninstalling pip-8.1.2:
      Successfully uninstalled pip-8.1.2
  Running install for pip ... done
Successfully installed pip-21.0

How to Solve Python Pip broken with sys.stderr.write(f“ERROR: {exc}”)?


Question: How to Solve Python Pip broken with sys.stderr.write(f“ERROR: {exc}”)?
Answer: You can get an older version (2.7) of curl –output In my opinion, you should


You can get an older version (2.7) of

curl --output

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 --output   # get pip for python2
python        # install pip in your virtualenv
pip install cuckoo       # install your python2 package

Hope it will help.


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 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"


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.


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

curl -o

Enjoy it!


Its version conflict issue. first check python –version, below steps for python version 2.7

  1. curl -o
  2. python
  3. install virtual env: python -m pip install –user virtualenv
  4. create venv: python -m virtualenv env
  5. activate venv: source env/bin/activate


If this logic is used in a (e.g.) Github Actions matrix of different Python versions, the following bash snippet will determine if pip should be updated before pip 21.0 or not. For instance, Python 3.5 should not update beyond pip 21.0, but Python 3.6 can use more recent versions.

use_pip_lt_21=`python -c "import sys; print(sys.version_info[:2] < (3, 6))"`
if [ $use_pip_lt_21 = "True" ]; then
  pip="pip < 21.0"
pip install --disable-pip-version-check --upgrade "$pip"


It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment