pip让我升级了一条消息:
You are using pip version 7.0.1, however version 7.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
所以我运行了该命令,我得到一个例外,pip无法卸载旧版本,因为访问我的用户目录被拒绝:
Collecting pip Downloading pip-7.0.3-py2.py3-none-any.whl (1.1MB) 100% |################################| 1.1MB 292kB/s Installing collected packages: pip Found existing installation: pip 7.0.1 Uninstalling pip-7.0.1: Successfully uninstalled pip-7.0.1 Exception: Traceback (most recent call last): File "C:\Python27\lib\site-packages\pip\basecommand.py", line 223, in main status = self.run(options, args) File "C:\Python27\lib\site-packages\pip\commands\install.py", line 297, in run root=options.root_path, File "C:\Python27\lib\site-packages\pip\req\req_set.py", line 633, in install requirement.commit_uninstall() File "C:\Python27\lib\site-packages\pip\req\req_install.py", line 734, in commit_uninstall self.uninstalled.commit() File "C:\Python27\lib\site-packages\pip\req\req_uninstall.py", line 153, in commit rmtree(self.save_dir) File "C:\Python27\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f return Retrying(*dargs, **dkw).call(f, *args, **kw) File "C:\Python27\lib\site-packages\pip\_vendor\retrying.py", line 212, in call raise attempt.get() File "C:\Python27\lib\site-packages\pip\_vendor\retrying.py", line 247, in get six.reraise(self.value[0], self.value[1], self.value[2]) File "C:\Python27\lib\site-packages\pip\_vendor\retrying.py", line 200, in call attempt = Attempt(fn(*args, **kwargs), attempt_number, False) File "C:\Python27\lib\site-packages\pip\utils\__init__.py", line 89, in rmtree onerror=rmtree_errorhandler) File "C:\Python27\lib\shutil.py", line 247, in rmtree rmtree(fullname, ignore_errors, onerror) File "C:\Python27\lib\shutil.py", line 247, in rmtree rmtree(fullname, ignore_errors, onerror) File "C:\Python27\lib\shutil.py", line 252, in rmtree onerror(os.remove, fullname, sys.exc_info()) File "C:\Python27\lib\site-packages\pip\utils\__init__.py", line 101, in rmtree_errorhandler func(path) WindowsError: [Error 5] Access is denied: 'c:\\users\\chris\\appdata\\local\\temp\\pip-ossyhh-uninstall\\python27\\scripts\\pip.exe'
我正在运行Windows 8.1,但我在另一台运行Windows 7的计算机上遇到了同样的错误。它似乎没有停止安装新版本,但我最终确实pip文件夹留在我的临时目录中。有谁知道为什么会发生这种情况或我如何纠正它?
EDIT1: 奇怪的是,使用admin privlidges运行升级会引发 new 异常:
File "C:\Python27\lib\site-packages\pip-7.0.1-py2.7.egg\pip\_vendor\distlib\scripts.py", line 302, in _get_launcher
result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'`
完全没有完成升级。
EDIT2: 解决这个问题的唯一方法似乎是使用easy_install来升级pip(-U或-m选项),但是如果pip不能自我升级,那么对我来说似乎是一个问题(并声明)功能是这样做的。
答案 0 :(得分:5)
这里的问题显然是因为您正在运行pip.exe
来升级自己。因此,要删除的pip.exe
实际上正在运行。修复方法是使用稍微不同的命令行:
python -m pip install --upgrade pip
这是来自bug report(虽然还有其他人):
•访问被拒绝:'... pip.exe'是因为你正在升级pip 使用pip.exe包装器在升级中被替换。上 Windows无法替换使用中的可执行文件/ DLL。你应该用 python -m pip install --upgrade pip。 IIRC注意到这一点 文档。
答案 1 :(得分:3)
我最近在Windows 7机器上遇到了同样的问题。我以管理员身份运行命令提示符(来自您的评论),然后输入pip install --upgrade pip
。
它从wazoo返回错误消息,但是当我再次尝试(pip install --upgrade pip
)时,它告诉我pip已经是最新的。然后pip -V
告诉我,我有点7.0.3。
不知道发生了什么。试图在Windows上获取python包似乎非常困难。希望这很有帮助。
另外,我使用的是python 3.5,可能会有所不同。
答案 2 :(得分:0)
我在使用pip-7.1.2版本安装matplotlib时遇到了问题,因此我将其升级到pip 9.0.1。
然而,更新它时给了我一个拒绝访问pip.exe的错误,但当我使用pip -v检查版本时它已更新。我只是运行pip install matplotlib。它对我有用。
D:\Users\703186511>pip install --upgrade pip
或尝试
D:\Users\703186511>python -m pip install --upgrade pip
D:\Users\703186511>pip -V
D:\Users\703186511>pip install matplotlib
答案 3 :(得分:-2)
我遇到了同样的问题。我只是在我的mac终端上使用了SUDO命令并且它工作正常。下面是终端输出。
sudo pip install -U pip
Anuvrats-MacBook-Air:~ anuvrattiku$ pip -V
pip 7.1.2 from /Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg (python 2.7)
Anuvrats-MacBook-Air:~ anuvrattiku$ **sudo pip install -U pip**
Password:
The directory '/Users/anuvrattiku/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/anuvrattiku/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading pip-8.0.2-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 272kB/s
Installing collected packages: pip
Found existing installation: pip 7.1.2
Uninstalling pip-7.1.2:
Successfully uninstalled pip-7.1.2
Successfully installed pip-8.0.2
Anuvrats-MacBook-Air:~ anuvrattiku$