解决ImportError: cannot import name 'SCHEME_KEYS'
解决ImportError: cannot import name 'SCHEME_KEYS'
今天用pip装一个库的时候,突然发现报下面这样的错:
Traceback (most recent call last):
File "/home/linxu/Apps/Anaconda3/envs/Paddle/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
File "/home/linxu/Apps/Anaconda3/envs/Paddle/lib/python3.6/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/linxu/Apps/Anaconda3/envs/Paddle/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/linxu/Apps/Anaconda3/envs/Paddle/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/home/linxu/Apps/Anaconda3/envs/Paddle/lib/python3.6/site-packages/pip/_internal/cli/cmdoptions.py", line 25, in <module>
from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
File "/home/linxu/Apps/Anaconda3/envs/Paddle/lib/python3.6/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
from pip._internal.models.scheme import SCHEME_KEYS, Scheme
ImportError: cannot import name 'SCHEME_KEYS'
于是试了很多种方法,发现都比较复杂,更有人说需要重装虚拟环境,最后想了一下或许直接重装pip就可以解决问题,因为conda创建的虚拟环境,pip本身也是依赖于conda来进行安装的。
于是,就直接尝试:
conda remove pip
conda install pip
最后问题就这样得到解决,终于舒服了。
Talk is cheap. Show me the code