Windows 10 和 pip 升级 - 拒绝访问 [英] Windows 10 and pip upgrading - Access denied

查看:61
本文介绍了Windows 10 和 pip 升级 - 拒绝访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了全新的 Windows 10 安装,安装了 python、cygwin 和一个名为 ConEmu 的改进控制台.安装python 3.4.3后我执行:

I have done a fresh Windows 10 install, installed python, cygwin and a improved console called ConEmu. After installing python 3.4.3 I execute:

pip install -U pip

并得到这个错误.

File "C:AnwendungsentwicklungPython34libsite-packagespiputils\__init__.py", line 70, in rmtree_errorhandler
  os.makedirs(path)
PermissionError: [WinError 5] Zugriff verweigert:  'C:\Users\ADMINI~1\AppData\Local\Temp\pip-dxm8d3xg-uninstall\anwendungsentwicklung\python34\scripts\pip.exe'

我使用预定义的管理员帐户登录,临时目录以及 Python 的安装目录 (C:AnwendungsentwicklungPython34) 具有完全访问权限.

I'm logged in with pre-defined Administrator account and the temp dir as well as the installation dir of Python (C:AnwendungsentwicklungPython34) has full access.

我已经通过设置不同的权限测试了所有变体,但 Windows 不允许我这样做.我什至在安全选项卡中添加了每个人",但这并没有帮助,尽管我记得它在 Windows 7 上使用了这个技巧".一定是 Windows 10 的问题.有人可以帮忙吗??

Please I have tested all variations by setting different rights but Windows won't let me. I even added "Everyone" to security tab but this didn't help although I remember it was working with Windows 7 with this "trick". It must be a problem with Windows 10. Can someone help??

这是完整的追溯

  Exception:
Traceback (most recent call last):
File "c:anwendungsentwicklungpython34libshutil.py", line 372, in  _rmtree_unsafe
  os.unlink(fullname)
PermissionError: [WinError 5] Zugriff verweigert:  'C:\Users\ADMINI~1\AppData\Local\Temp\pip-k7g0hd6t- uninstall\anwendungsentwicklung\python34\scripts\pip.exe'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:anwendungsentwicklungpython34libsite-packagespipasecommand.py", line 232, in main
  logger.critical('Operation cancelled by user')
File "c:anwendungsentwicklungpython34libsite-packagespipcommandsinstall.py", line 347, in run
  ensure_dir(options.target_dir)
File "c:anwendungsentwicklungpython34libsite-packagespip
eq
eq_set.py", line 560, in install
  missing_requested = sorted(
File "c:anwendungsentwicklungpython34libsite-packagespip
eq
eq_install.py", line 677, in commit_uninstall
  logger.debug(
File "c:anwendungsentwicklungpython34libsite-packagespip
eq
eq_uninstall.py", line 153, in commit
  self.save_dir = None
File "c:anwendungsentwicklungpython34libsite-packagespiputils\__init__.py", line 58, in rmtree
  SUPPORTED_EXTENSIONS = ZIP_EXTENSIONS + TAR_EXTENSIONS
File "c:anwendungsentwicklungpython34libshutil.py", line 484, in rmtree
  return _rmtree_unsafe(path, onerror)
File "c:anwendungsentwicklungpython34libshutil.py", line 368, in _rmtree_unsafe
  _rmtree_unsafe(fullname, onerror)
File "c:anwendungsentwicklungpython34libshutil.py", line 368, in _rmtree_unsafe
  _rmtree_unsafe(fullname, onerror)
File "c:anwendungsentwicklungpython34libshutil.py", line 368, in _rmtree_unsafe
  _rmtree_unsafe(fullname, onerror)
File "c:anwendungsentwicklungpython34libshutil.py", line 376, in _rmtree_unsafe
  print(fullname)
File "c:anwendungsentwicklungpython34libsite-packagespiputils\__init__.py", line 70, in rmtree_errorhandler
  try:
PermissionError: [WinError 5] Zugriff verweigert: 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-k7g0hd6t-uninstall\anwendungsentwicklung\python34\scripts\pip.exe'

现在我在c:anwendungsentwicklungpython34libshutil.py"中添加了一个断点:

Now I added a breakpoint in "c:anwendungsentwicklungpython34libshutil.py":

# version vulnerable to race conditions
def _rmtree_unsafe(path, onerror):
try:
    if os.path.islink(path):
        # symlinks to directories are forbidden, see bug #1669
        raise OSError("Cannot call rmtree on a symbolic link")
except OSError:
    onerror(os.path.islink, path, sys.exc_info())
    # can't continue even if onerror hook returns
    return
names = []
try:
    names = os.listdir(path)
except OSError:
    onerror(os.listdir, path, sys.exc_info())
for name in names:
    fullname = os.path.join(path, name)
    try:
        mode = os.lstat(fullname).st_mode
    except OSError:
        mode = 0
    if stat.S_ISDIR(mode):
        _rmtree_unsafe(fullname, onerror)
    else:
        try:
            #import pdb
            os.unlink(fullname)
            #pdb.set_trace()
        except OSError:
            import pdb; pdb.set_trace()
            print(fullname)
            import getpass
            print(getpass.getuser())
            onerror(os.unlink, fullname, sys.exc_info())
try:
    os.rmdir(path)
except OSError:
    onerror(os.rmdir, path, sys.exc_info())

当我执行

os.unlink(fullname) # 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-k7g0hd6t- uninstall\anwendungsentwicklung\python34\scripts\pip.exe'

我得到这个PermissionError,所以我用

oct(os.stat(fullname)[ST_MODE])

它返回:'0o100777'

and it returns: '0o100777'

如果我是对的,这意味着对每个人(所有者、群组和其他人)的完全许可.

And when i'm right, this means full permission for everyone (owner, group and others).

我很沮丧:/有人有想法吗?

I'm frustrated :/ Someone an idea?

推荐答案

正如讨论的 这里,这是 Windows 的限制.简而言之,pip.exe 文件正在使用中,因此被锁定且无法删除.使用 python -m pip install --upgrade pip.

As discussed here, it's a Windows limitation. In brief, the pip.exe file is in use and thus locked and can't be deleted. Use python -m pip install --upgrade pip.

这篇关于Windows 10 和 pip 升级 - 拒绝访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆