我在Windows 7上安装了Python 3.4.1,包含了pip,在安装过程中选择了将python.exe添加到PATH。
运行pip安装请求时,我得到:
C:\Python34>pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in c:\python3
4\lib\site-packages
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\shutil.py", line 370, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\User\\AppData\\Local
\\Temp\\pip_build_User\\pip\\pip\\_vendor\\distlib\\w32.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 302, in run
requirement_set.cleanup_files(bundle=self.bundle)
File "C:\Python34\lib\site-packages\pip\req.py", line 1333, in cleanup_files
rmtree(dir)
File "C:\Python34\lib\site-packages\pip\util.py", line 43, in rmtree
onerror=rmtree_errorhandler)
File "C:\Python34\lib\shutil.py", line 477, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 372, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python34\lib\site-packages\pip\util.py", line 53, in rmtree_errorhand
ler
(exctype is PermissionError and value.args[3] == 5) #python3.3
IndexError: tuple index out of range
Storing debug log for failure in C:\Users\User\pip\pip.log
当运行pip install beautifulsoup4时,我得到:
C:\Python34>pip install beautifulsoup4
Downloading/unpacking beautifulsoup4
Running setup.py (path:C:\Users\User\AppData\Local\Temp\pip_build_User\beautif
ulsoup4\setup.py) egg_info for package beautifulsoup4
Installing collected packages: beautifulsoup4
Running setup.py install for beautifulsoup4
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
Successfully installed beautifulsoup4
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\shutil.py", line 370, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\User\\AppData\\Local
\\Temp\\pip_build_User\\pip\\pip\\_vendor\\distlib\\w32.exe'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 302, in run
requirement_set.cleanup_files(bundle=self.bundle)
File "C:\Python34\lib\site-packages\pip\req.py", line 1333, in cleanup_files
rmtree(dir)
File "C:\Python34\lib\site-packages\pip\util.py", line 43, in rmtree
onerror=rmtree_errorhandler)
File "C:\Python34\lib\shutil.py", line 477, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 372, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python34\lib\site-packages\pip\util.py", line 53, in rmtree_errorhand
ler
(exctype is PermissionError and value.args[3] == 5) #python3.3
IndexError: tuple index out of range
Storing debug log for failure in C:\Users\User\pip\pip.log
C:\Python34>
我想知道那些例外是什么意思?
让包真的成功安装,如日志中给出的那样,它们运行正常还是我做错了。
为什么例外以及如何摆脱它们?
答案 0 :(得分:8)
所有权限异常都意味着您的命令提示符没有管理员权限。
以管理员身份运行命令提示符(在开始菜单中搜索cmd,右键单击,以管理员身份运行)。如果这不起作用,请尝试重新安装pip;文件权限可能会以某种方式搞砸了。