Ama*_*bek 1 python pip permission-denied
我尝试通过键入终端使用pip安装python库openpyxl:
pip install openpyxl
Run Code Online (Sandbox Code Playgroud)
但它没有正确执行.它引发了一个例外:
Successfully built openpyxl jdcal et-xmlfile
Installing collected packages: jdcal, et-xmlfile, openpyxl
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 323, in clobber
shutil.copyfile(srcfile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/jdcal.py'
Run Code Online (Sandbox Code Playgroud)
最好的方法是使用 pip install <libname> --user
在你的情况下使用意义 pip install openpyxel --user
这将为您的用户安装包,这是安全的.您也可能有权为用户安装软件包.
您遇到的权限错误是一个常见问题.从这里可以看出: pip无法正确安装包:权限被拒绝错误 和此处错误:无法创建'/usr/local/lib/python2.7/dist-packages/virtualenv_support':权限被拒绝
使用sudo pip命令不被认为是安全的,如下所述:运行'sudo pip'有什么风险?
归档时间: |
|
查看次数: |
13179 次 |
最近记录: |