I somehow managed to mess up my system-wide Python3 installation for my fresh MacOS Catalina installation. The problem is with pip – I upgraded the system pip version with sudo pip3 install --upgrade pip
. After doing so, I got error messages from pip saying:
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue. To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Then, in a (failed) attempt to downgrade pip to the previous version to remove this error, I uninstalled this version of pip with sudo pip3 uninstall pip
- not my smartest move, I know. Now, with pip3 –version
I get the following output:
Traceback (most recent call last): File "/Library/Developer/CommandLineTools/usr/bin/pip3", line 6, in <module> from pip._internal import main ModuleNotFoundError: No module named 'pip'
I know I can install other versions of python and pip with brew (this is what I am currently doing), but I know that a fair number of system services and applications rely on the system-installed python, so I would like to fix this issue.
sudo pip3 uninstall pip
will only uninstall pip, it won't uninstall python. You can just reinstall pip.
To reinstall pip:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --user
rm get-pip.py
Then you should run pip as python3 -m pip
instead of pip3
, or else create an alias for pip3
in your ~/.profile
(or ~/.bashrc
/ ~/.bash_aliases
for Linux bash users):
alias pip3='python3 -m pip'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.