Python---报错:from pip import main ImportError: cannot import name 'main'

当执行:

python3 -m pip install 模块名
sudo pip3 install XXX

报错:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

解决:
sudo gedit /usr/bin/pip3

#!/usr/bin/python3
# GENERATED BY DEBIAN

import sys

# Run the main entry point, similarly to how setuptools does it, but because
# we didn't install the actual entry point from setup.py, don't use the
# pkg_resources API.

# python2
#from pip import main
#if __name__ == '__main__':
#    sys.exit(main())

# python3
from pip import __main__
if __name__ == '__main__':  
    sys.exit(__main__._main())
原文地址:https://www.cnblogs.com/carle-09/p/12761361.html