pip安装提示PermissionError: [WinError 5]错误问题解决

时间:2017-07-18 23:13:01   收藏:0   阅读:27631

 问题现象

  新安装python3.6版本后使用pip安装第三方模块失败,报错信息如下:

C:\Users\linyfeng>pip install lxml
Collecting lxml
  Downloading http://pypi.doubanio.com/packages/fb/41/b8d5c869d01fcb77c72d7d226a847a3946034ef19c244ac12920b71cd036/lxml-3.8.0-cp36-cp36m-win32.whl (2.9MB)
    100% |████████████████████████████████| 2.9MB 4.6MB/s
Installing collected packages: lxml
Exception:
Traceback (most recent call last):
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\program files (x86)\python36-32\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 (x86)\python36-32\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "c:\program files (x86)\python36-32\lib\os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [WinError 5] 拒绝访问。: c:\\program files (x86)\\python36-32\\Lib\\site-packages\\lxml

问题分析

  提示错误很明显报错的是PermissionError,应该是权限不足。查找了下资料,确认使用登录账号为普通用户,需要使用administrator权限运行cmd。提供一种简单易操作的方法以administrator权限执行cmd,如下

(1) 查找cmd运行绝对路径

C:\Users\shiyanan>where cmd
C:\Windows\System32\cmd.exe

(2) 到C:\Windows\System32目录下,右键单击cmd.exe文件以管理员身份运行。如下

技术分享

技术分享

可以发现路径名变成了C:\Windows\system32>

(3) 重新执行pip install lxml,结果如下

C:\Windows\system32>pip install lxml
Collecting lxml
  Downloading http://pypi.doubanio.com/packages/fb/41/b8d5c869d01fcb77c72d7d226a847a3946034ef19c244ac12920b71cd036/lxml-3.8.0-cp36-cp36m-win32.whl (2.9MB)
    100% |████████████████████████████████| 2.9MB 6.8MB/s
Installing collected packages: lxml
Successfully installed lxml-3.8.0

(4) 结束

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!