python ImportError cannot import name SCHEME_KEYS

python运行问题

python -m pip

python3 -m pip
会出错

ImportError: cannot import name 'SCHEME_KEYS'

出现这个问题,原因可能是目前存在的pip安装不完全。

解决方法

  1. 执行 python3 -m ensurepip
    它会安装,或打印已经安装的pip,类似如下
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.
Defaulting to user installation because normal site-packages is not writeable
Looking in links: /tmp/tmpk6zjugs2
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (44.1.1)
Requirement already satisfied: pip in /usr/lib/python3.6/site-packages (21.3.1)

根据打印,把所有pip都删除,比如上面的/usr/lib/python3.6/site-packages/目录中的pip。
直到输入命令pip,报没有pip错误时才算删除干净。

  1. 然后再执行python3 -m ensurepip重新安装pip。
    作者:帅得不敢出门

你可能感兴趣的:(python,python,开发语言)