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'
I'm running Windows 8.1, but I've had this same Error on another machine running Windows 7. It doesn't seem to stop the installation of the new version, but I do end up with pip folders left in my temp directory. Does anyone know why this happens or how I can correct it?
Edit1: Oddly, running the upgrade with admin privlidges throws a new exception:
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'`
并且升级完全失败。
编辑2: 解决这个问题的唯一方法似乎是使用 easy_install 来升级 pip(-U 或 -m 选项),但如果 pip 无法在预期(并声明)时自行升级,对我来说似乎是个问题) 的功能是这样做。
最佳答案
这里的问题显然是因为您正在运行 pip.exe
来升级自身。所以要删除的pip.exe
其实当时正在运行。解决方法是使用稍微不同的命令行:
python -m pip install --upgrade pip
这是来自这个bug report (尽管还有其他):
• Access is denied: '... pip.exe' is because you're upgrading pip using the pip.exe wrapper which gets replaced in the upgrade. On Windows you can't replace in-use executables/DLLs. You should use python -m pip install --upgrade pip . IIRC this is noted in the documentation.
关于python - 在 Windows 上升级 pip.exe 时出现 "Access is denied",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30699782/