My Python is MESSED UP. I recently installed python3.6 and python3.7 using ppa:deadsnakes/ppa. I think I also may have tried to reinstall python 2.7 and python 3.5 (which I now understand is a big no-no because some OS features depend on proper Python always being configured). And there may have been other changes.
Currently:
python --version
Python 2.7.12
python2 --version
Python 2.7.12
python3 --version
Python 3.7.9
And I get the following:
pip -V
Traceback (most recent call last):
File "/home/<my_user>/.local/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
File "/home/<my_user>/.local/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
Which seems like pip contains python3 code, but is running python2.
Indeed:
python3 -m pip -V
gives
pip 21.0 from /home/<my_user>/.local/lib/python3.7/site-packages/pip (python 3.7)
Note that this is after I tried changing the first line of /home/<my_user>/.local/bin/pip to:
#!/usr/bin/python
(it was originally python3)
Does someone understand what's happening? How can I get pip -V
to return a version associated with python2 instead of crashing?
I'm running Ubuntu 16.04 LTS.
question from:
https://stackoverflow.com/questions/65890755/pip-defaults-to-python3 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…