pip更新及Requirement already up-to-date解决方法
文:铁乐与猫
2018-9-11
更新命令
- 将pip更新到最新版本
python -m pip install --upgrade pip
- Anaconda更新命令为
conda install mingw libpython
Requirement already up-to-date
在pycharm的虚拟环境中,特别容易出现运行更新pip的命令后,提示要求己经更新,但实际上查看版本还是没更新成功的情况:
(venv) E:FlaskBaiduAI>pip --version
pip 9.0.1 from e:flaskaiduaivenvlibsite-packagespip-9.0.1-py3.6.egg (python 3.6)
(venv) E:FlaskBaiduAI>python -m pip install --upgrade pip
Requirement already up-to-date: pip in e:flaskaiduaivenvlibsite-packages (18.0)
(venv) E:FlaskBaiduAI>pip --version
pip 9.0.1 from e:flaskaiduaivenvlibsite-packagespip-9.0.1-py3.6.egg (python 3.6)
直接使用pip install --upgrade pip
命令还会出现权限不足的报错:
(venv) E:FlaskBaiduAI>pip install --upgrade pip
Cache entry deserialization failed, entry ignored
Collecting pip
Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf94
0/pip-18.0-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 9.0.1
Uninstalling pip-9.0.1:
Exception:
Traceback (most recent call last):
File "D:PortableSoftPython36libshutil.py", line 544, in move
os.rename(src, real_dst)
OSError: [WinError 17] 系统无法将文件移到不同的磁盘驱动器。: 'e:\flask\baiduai\venv\scripts\pip.exe' -> 'C:\Users
ADMINI~1\AppData\Local\Temp\pip-76ifpsoa-uninstall\flask\baiduai\venv\scripts\pip.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "e:flaskaiduaivenvlibsite-packagespip-9.0.1-py3.6.eggpipasecommand.py", line 215, in main
File "e:flaskaiduaivenvlibsite-packagespip-9.0.1-py3.6.eggpipcommandsinstall.py", line 342, in run
File "e:flaskaiduaivenvlibsite-packagespip-9.0.1-py3.6.eggpip
eq
eq_set.py", line 778, in install
File "e:flaskaiduaivenvlibsite-packagespip-9.0.1-py3.6.eggpip
eq
eq_install.py", line 754, in uninstall
File "e:flaskaiduaivenvlibsite-packagespip-9.0.1-py3.6.eggpip
eq
eq_uninstall.py", line 115, in remove
File "e:flaskaiduaivenvlibsite-packagespip-9.0.1-py3.6.eggpiputils\__init__.py", line 267, in renames
File "D:PortableSoftPython36libshutil.py", line 559, in move
os.unlink(src)
PermissionError: [WinError 5] 拒绝访问。: 'e:\flask\baiduai\venv\scripts\pip.exe'
这简直是死循环了,使用python -m pip install --upgrade pip -vvv
报了一大堆信息,然而也没有什么卵用。
后来细想有可能是因为我之前是使用pycharm尝试升级虚拟环境里的pip版本,显示是成功升级到18.0了的缘故。
有及于此,最后我是跑到E:FlaskBaiduAIvenvLibsite-packages
目录下查看,发现了在没有安装成功18.0版本的时候此目录下就己存在pip-18.0.dist-info
,有毛病。
于是大胆尝试将pip-18.0.dist-info
目录删除后,继续在虚拟环境下重新更新pip,终于成功!
(venv) E:FlaskBaiduAI>python -m pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf94
0/pip-18.0-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-18.0
(venv) E:FlaskBaiduAI>pip --version
pip 18.0 from e:flaskaiduaivenvlibsite-packagespip (python 3.6)
这个报错告诉我,尽量选择在cmd命令行下手动更新pip或其它软件包,而不要选择在pycharm的界面下直接用鼠标点升级……
【end】