python - PIP 升级权限被拒绝 Windows 10

标签 python django python-3.x pip

Python 3.6.5 和(当前)pip 9.0.3 尝试升级到 10.0.1。

我已经检查了各种SO线程,但没有什么能让我到达那里。当尝试 pip 安装任何东西并升级 pip 本身时,我不断收到以下消息:

这是当我尝试安装 Django 时,它告诉我需要升级 pip。

异常(exception):

Traceback (most recent call last):

File "c:\program files\python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)

File "c:\program files\python36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,

File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs

File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)

File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,

File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)

File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 316, in clobber
    ensure_dir(destdir)

File "c:\program files\python36\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir
    os.makedirs(path)

File "c:\program files\python36\lib\os.py", line 220, in makedirs
    mkdir(name, mode)

PermissionError: [WinError 5] Access is denied: 'c:\\program files\\python36\\Lib\\site-packages\\pytz'
<小时/>

这是我尝试使用 python -m pip install --upgrade pip 升级 pip 之后的结果:

异常(exception):

Traceback (most recent call last):

File "C:\Program Files\Python36\lib\shutil.py", line 544, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied:** 'c:\\program files\\python36\\lib\\site-packages\\pip-9.0.3.dist-info\\description.rst' -> 'C:\\Users\\johns\\AppData\\Local\\Temp\\pip-f8ej9z71-uninstall\\program files\\python36\\lib\\site-packages\\pip-9.0.3.dist-info\\description.rst'

During handling of the above exception, **another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Program Files\Python36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,

File "C:\Program Files\Python36\lib\site-packages\pip\req\req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)

File "C:\Program Files\Python36\lib\site-packages\pip\req\req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)

File "C:\Program Files\Python36\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove
    renames(path, new_path)

File "C:\Program Files\Python36\lib\site-packages\pip\utils\__init__.py", line 267, in renames
    shutil.move(old, new)

File "C:\Program Files\Python36\lib\shutil.py", line 559, in move
    os.unlink(src)

PermissionError: [WinError 5] Access is denied: 'c:\\program files\\python36\\lib\\site-packages\\pip-9.0.3.dist-info\\description.rst'

我在我的上一台电脑上没有遇到这个问题,所以我有 pip 困惑。我不明白为什么我会出现权限错误,我是管理员。我试过sudo (但我认为这只是Mac?)。我查看了有关如何执行此操作的存储库讨论以及 pip 文档。而且我相当确定在安装时将 Python 添加到了 Path 中。

谢谢你帮我解决这个问题。

最佳答案

尝试通过单击“以管理员身份运行”来打开命令提示符或 Powershell。 您可以在这个video中找到步骤.

关于python - PIP 升级权限被拒绝 Windows 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50790321/

相关文章:

python - 如何在 Django 的同一页面上拆分帖 subview

python - 寻找不匹配模式的效率

Python 导入错误 : 'module' object has no attribute 'x'

python-3.x - 将图像保存为字节并上传到 boto3 返回内容 MD5 不匹配

Python 重力模拟器表现奇怪

python - 没有名为 'keras.legacy' 的模块

mysql - sudo supervisorctl 状态 : gumi gunicorn ERROR (spawn error)

python - np.random.randint : ValueError: low >= high

python - 二进制 numpy 数组之间的快速汉明距离计算

django - Django 中的 render() 和 redirect() 有什么区别?