软件版本: 我使用的python是安装Anaconda时自带的3.6版本。
今天更新一下pip,结果跟新失败,并导致pip不能使用了,报错如下:
C:\WINDOWS\system32>pip -V
Traceback (most recent call last):File "e:\software\pycharm\anaconda\setup\lib\runpy.py", line 193, in _run_module_as_main"__main__", mod_spec)File "e:\software\pycharm\anaconda\setup\lib\runpy.py", line 85, in _run_codeexec(code, run_globals)File "E:\software\pycharm\Anaconda\setup\Scripts\pip.exe\__main__.py", line 5, in
ModuleNotFoundError: No module named 'pip'
按照网上的教程,一般的方法是:
python -m ensurepip
python -m pip install --upgrade pip
好像确实很多人通过这个解决了,但是很遗憾我运行python -m ensurepip
报错了,提示:
C:\WINDOWS\system32>python -m ensurepip
E:\software\pycharm\Anaconda\setup\python.exe: No module named ensurepip
找了很多也没有找到类似解决这个问题的,于是考虑使用conda
来重新安装pip
,命令为conda install pip
,意外再次发生了,如下:
ERROR conda.core.link:_execute_actions(337): An error occurred while installing package 'defaults::tqdm-4.48.2-py_0'.
CondaError: Cannot link a source that does not exist. E:\software\pycharm\Anaconda\setup\Scripts\conda.exe
Running `conda clean --packages` may resolve your problem.
Attempting to roll back.
于是按照提示conda clean --packages
,清楚了无用的安装包后,依然不行,于是参考了网上的建议,使用了命令conda install pip -f
, 终于好了~~~~
C:\WINDOWS\system32>conda install pip -f
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment E:\software\pycharm\Anaconda\setup:
The following packages will be UPDATED:pip: 9.0.1-py36hadba87b_3 --> 20.2.2-py36_0
Proceed ([y]/n)? y
C:\WINDOWS\system32>pip -V
pip 20.2.2 from E:\software\pycharm\Anaconda\setup\lib\site-packages\pip (python 3.6)
参考:
1.ERROR conda.core.link:_execute_actions(337): An error occurred while installing package 问题解决办法 ,https://blog.csdn.net/weixin_40592798/article/details/105940860
2.pip升级出错 ModuleNotFoundError: No module named pip的解决办法,https://blog.csdn.net/qq_36936730/article/details/106663444