Traceback (most recent call last): File "/usr/bin/pip3", line 9, in <module> f

2019-09-29 16:28:42 浏览数 (1)

代码语言:javascript复制
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

python3设置默认源时报错

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

输入命令

代码语言:javascript复制
sudo /usr/bin/pip3

代码语言:javascript复制
from pip import main
if __name__ == '__main__':
    sys.exit(main())

改为

代码语言:javascript复制
from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__._main())

0 人点赞