. Advertisement .
..3..
. Advertisement .
..4..
The error: “Python Pip broken wiith sys.stderr.write(f“ERROR: {exc}”)” is a common error that can show up in many ways. In this blog, we will go through some of the ways you can fix this issue. Read on.
When Does The Error: “Python Pip broken wiith sys.stderr.write(f“ERROR: {exc}”)” Happen?
Python has been installed on CentOS-7. I’d like to make a change to my pip. To upgrade my pip, I just execute the command pip install –upgrade pip.
When I update Pip, I discover that my Python has become unusable. All pip instructions after that end in SyntaxError.
Collecting pip
Using cached https://files.pythonhosted.org/packages/9e/24/bc928987f35dd0167f21b13a1777c21b9c5917c9894cff93f1c1a6cb8f3b/pip-21.0.tar.gz
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Running setup.py install for pip ... done
Successfully installed pip-21.0
[[email protected] ~]# /usr/bin/pip2 install --upgrade pip setuptools pyOpenSSL psycopg2-binary lxml
Traceback (most recent call last):
File "/usr/bin/pip2", line 9, in <module>
load_entry_point('pip==21.0', 'console_scripts', 'pip2')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
How To Solve The Error: “Python Pip broken wiith sys.stderr.write(f“ERROR: {exc}”)”?
Approach 1: Update pip to the current version
This issue arises as a result of the PIP community’s decision to reduce support to 2.7. So all you have to do now is update pip to the current version to resolve the error ”Python Pip broken wiith sys.stderr.write(f“ERROR: {exc}”)”.
DEPRECATION: On January 1st, 2020, Python 2.7 reached the end of its support period. Python 2.7 is no longer supported, therefore please update your Python. In January 2021, pip 21.0 will stop supporting Python 2.7. On release process, you can find out more information about Python 2 support in pip. Pip 21.0 will stop supporting this feature.
To solve this and keep using unsupported Python 2.7, downgrade to version 21 rather than the most recent pip version.
pip install --upgrade "pip < 21.0"
Approach 2: Download an earlier version (2.7) of get-pip.py
You can download an earlier version (2.7) of get-pip.py to fix the error “Python Pip broken wiith sys.stderr.write(f“ERROR: {exc}”)”. Although this is a simple method, it’s very effective. Let’s do it to get your desired result.
Approach 3: Follow these steps
In the case you don’t want to use Python 2, let’s follow these steps to fix your error.
- Step 1:
1. Run the following command:
which pip
2. Remember the location because later you perhaps will need it.
- Step 2: Backup the outcome(s) of the aforementioned command.
- Step 3: Remove the file(s) in step 1.1.
- Step 4: Run the below commands:
sudo apt install python-pip
sudo easy_install pip==20.3.4
- Step 5: Run it again:
which pip3
- Step 6: Run the following command:
sudo ln -s /path/to/pip3 /path/to/pip
However, you need to replace “/path/to/pip3/” with the outcomes of step 5, and “/path/to/pip” with the position specified in step 1.1.
Conclusion
We hope you enjoyed our article about the error. With this knowledge, we know that you can fix your error: “Python Pip broken wiith sys.stderr.write(f“ERROR: {exc}”)” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Read more
Leave a comment