错误:无法创建“/Library/Python/2.7/site-packages/xlrd”:权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18199853/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error: could not create '/Library/Python/2.7/site-packages/xlrd': Permission denied
提问by Sammy
I'm trying to install xlrd on mac 10.8.4 to be able to read excel files through python.
我正在尝试在 mac 10.8.4 上安装 xlrd 以便能够通过 python 读取 excel 文件。
I have followed the instructions on http://www.simplistix.co.uk/presentations/python-excel.pdf
我已按照http://www.simplistix.co.uk/presentations/python-excel.pdf上的说明进行操作
I did this:
我这样做了:
unzipped the folder to desktop
in terminal, cd to the unzipped folder
$ python setup.py install
将文件夹解压到桌面
在终端中,cd 到解压文件夹
$ python setup.py 安装
This is what I get:
这就是我得到的:
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/xlrd
copying xlrd/__init__.py -> build/lib/xlrd
copying xlrd/biffh.py -> build/lib/xlrd
copying xlrd/book.py -> build/lib/xlrd
copying xlrd/compdoc.py -> build/lib/xlrd
copying xlrd/formatting.py -> build/lib/xlrd
copying xlrd/formula.py -> build/lib/xlrd
copying xlrd/info.py -> build/lib/xlrd
copying xlrd/licences.py -> build/lib/xlrd
copying xlrd/sheet.py -> build/lib/xlrd
copying xlrd/timemachine.py -> build/lib/xlrd
copying xlrd/xldate.py -> build/lib/xlrd
copying xlrd/xlsx.py -> build/lib/xlrd
creating build/lib/xlrd/doc
copying xlrd/doc/compdoc.html -> build/lib/xlrd/doc
copying xlrd/doc/xlrd.html -> build/lib/xlrd/doc
creating build/lib/xlrd/examples
copying xlrd/examples/namesdemo.xls -> build/lib/xlrd/examples
copying xlrd/examples/xlrdnameAPIdemo.py -> build/lib/xlrd/examples
running build_scripts
creating build/scripts-2.7
copying and adjusting scripts/runxlrd.py -> build/scripts-2.7
changing mode of build/scripts-2.7/runxlrd.py from 644 to 755
running install_lib
creating /Library/Python/2.7/site-packages/xlrd
error: could not create '/Library/Python/2.7/site-packages/xlrd': Permission denied
Why is permission denied? Thanks
为什么权限被拒绝?谢谢
采纳答案by arynhard
try sudo python setup.py install
尝试 sudo python setup.py install
the /Library folder needs root permission to be accessed.
/Library 文件夹需要 root 权限才能访问。
回答by Louis Maddox
Try python setup.py install --user
尝试 python setup.py install --user
You shouldn't use sudo
as suggested above for two reasons:
sudo
由于两个原因,您不应该按照上述建议使用:
- You're allowing arbitrary untrusted code off the internet to be run as root
- Passing the
--user
flag topython setup.py install
will install the package to a user-owned directory. Your normal non-root user won't be able to access the files installed bysudo pip
orsudo python setup.py
- 您允许 Internet 上的任意不受信任的代码以 root 身份运行
- 传递
--user
标志 topython setup.py install
会将包安装到用户拥有的目录。您的普通非 root 用户将无法访问由sudo pip
或sudo python setup.py
回答by Nitin
Try in a virtualenv
:
尝试virtualenv
:
- sudo pip install virtualenvwrapper
- mkvirtualenv
- workon
- python setup.py install
- 须藤 pip 安装 virtualenvwrapper
- mkvirtualenv
- 从事于
- python setup.py 安装