[英]Installing python module IOError: [Errno 13] Permission denied:
I tried to install the python library openpyxl using pip by typing into the terminal: 我试图通过在终端中输入pip来安装python库openpyxl:
pip install openpyxl
But it was not executed properly. 但是执行不正确。 It threw an exception:
它引发了一个异常:
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'
Best way is probably to use pip install <libname> --user
最好的方法可能是使用
pip install <libname> --user
Meaning in your case use pip install openpyxel --user
在您的情况下意味着使用
pip install openpyxel --user
This installs the package for your user and that is safe. 这将为您的用户安装该软件包,这是安全的。 Also you have probably the right of installing the package for the user.
您也可能有权为用户安装软件包。
The permission error you have encountered is a frequent problem. 您遇到的权限错误是一个常见问题。 As can be seen here: pip is not able to install packages correctly: Permission denied error and here error: could not create '/usr/local/lib/python2.7/dist-packages/virtualenv_support': Permission denied
如此处所示: pip无法正确安装软件包:权限被拒绝错误 ,此处错误:无法创建'/usr/local/lib/python2.7/dist-packages/virtualenv_support':权限被拒绝
Using the sudo pip command is not considered as safe as explained here: What are the risks of running 'sudo pip'? 使用sudo pip命令并不安全,如下所述: 运行“ sudo pip”有什么风险?
Your user doesn't have write permissions in the Python installation folder. 您的用户在Python安装文件夹中没有写权限。
To fix it, run pip as root: 要解决此问题,请以root身份运行pip:
sudo pip install openpyxl
Your account does not have write access to this directory?. 您的帐户对此目录没有写权限?。
If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account. 如果安装目录是系统拥有的目录,则可能需要以管理员或“ root”帐户登录。
sudo pip install openpyxl sudo pip安装openpyxl
If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHON_PATH environment variable. 如果您没有对此计算机的管理访问权限,则可能希望选择其他安装目录,最好是PYTHON_PATH环境变量中列出的安装目录。
easier way: change that dir permission: 更简单的方法:更改该目录权限:
chmod +a 'user:YOUR_USER_NAME allow add_subdirectory,add_file,delete_child,directory_inherit' /Library/Python/2.7/site-packages chmod + a'用户:YOUR_USER_NAME允许添加子目录,添加文件,删除子级,目录继承'/Library/Python/2.7/site-packages
将您的用户的site-packages文件夹的安全设置更改为“完全控制”,然后重新运行pip install openpyxl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.