jwenjian / ghiblog

GitHub Issues Blog, powered by GitHub Issues and GitHub Actions
https://1link.fun
350 stars 47 forks source link

解决:pip3 cannot import name main #152

Open jwenjian opened 4 years ago

jwenjian commented 4 years ago

linux环境下,安装pip3之后,执行了下面的命令:

wenjian@localdev:~/service$ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U
Collecting pip
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
    100% | 1.4MB 1.0MB/s
Installing collected packages: pip
Successfully installed pip-19.3.1

但是之后再执行 pip3 命令时,报下面的错:

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

解决方案

执行下面这行命令即可:

wenjian@localdev:~/service$ python3 -m pip uninstall pip
Uninstalling pip-19.3.1:
  Would remove:
    /home/wenjian/.local/bin/pip
    /home/wenjian/.local/bin/pip3
    /home/wenjian/.local/bin/pip3.6
    /home/wenjian/.local/lib/python3.6/site-packages/pip-19.3.1.dist-info/*
    /home/wenjian/.local/lib/python3.6/site-packages/pip/*
Proceed (y/n)? y
  Successfully uninstalled pip-19.3.1