Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip: sys.stderr.write(f"ERROR: {exc}") with Python 3.5 [duplicate]

Tags:

python

pip

i am having a trouble with pip and pip3. I am trying to install requirements and it shows an error. When i write pip3 or pip --version it show this error.

jumphost@jumphost-VirtualBox:~$ pip3 --version
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import __main__
  File "/usr/local/lib/python3.5/dist-packages/pip/__main__.py", line
21, in <module>
    from pip._internal.cli.main import main as _main
  File
"/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

If i am trying to install, it showed this

jumphost@jumphost-VirtualBox:~/kubespray$ pip install -r requirements.txt
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import __main__
  File
"/usr/local/lib/python2.7/dist-packages/pip-21.0-py2.7.egg/pip/__main__.py",
line 21, in <module>
    from pip._internal.cli.main import main as _main
  File
"/usr/local/lib/python2.7/dist-packages/pip-21.0-py2.7.egg/pip/_internal/cli/main.py",
line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax
jumphost@jumphost-VirtualBox:~/kubespray$ pip3 install -r requirements.txt
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import __main__
  File "/usr/local/lib/python3.5/dist-packages/pip/__main__.py", line
21, in <module>
    from pip._internal.cli.main import main as _main
  File
"/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

I didn't found a right answer so this is the reason why i ask you. Thanks ! I tried remove python, pip, python3 and pip3 multipletimes but still same problem.

like image 948
Tomáš Mejzr Avatar asked Feb 15 '21 17:02

Tomáš Mejzr


1 Answers

pip has dropped support for Python 2 and 3.5. You will need to use a version-specific branch, assuming that your Python version is 3.5:

curl -fsSL https://bootstrap.pypa.io/pip/3.5/get-pip.py | python3.5

get-pip.py reference: https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py

Related: How can I install a legacy PIP version with python 2.6.6 or python 2.7.5?

Better yet, as suggested in the comments, install a newer version of Python that is not end-of-life.

like image 131
Brad Solomon Avatar answered Oct 19 '22 06:10

Brad Solomon