在没有sudo的情况下为Python安装包时如何避免权限被拒绝
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22551461/
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
how to avoid Permission denied while installing package for Python without sudo
提问by Anthony
I am trying to install the tesseractwrapper for python as user mikeso that I can import tesseract. I'm following the guide here https://code.google.com/p/python-tesseract/wiki/HowToCompilePythonTesseractForCentos
我正在尝试以tesseract用户身份安装python的包装器,mike以便我可以import tesseract. 我在这里遵循指南https://code.google.com/p/python-tesseract/wiki/HowToCompilePythonTesseractForCentos
However, when I execute python setup.py install
但是,当我执行 python setup.py install
I get the error below:
我收到以下错误:
[Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/test-easy-install-7351.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python2.7/site-packages/
I do have sudo access but here is the problem: When I login as rootthe default python version is 2.6, however, when I login as mikethe default python version is 2.7(this is the one I want). So if I do sudo python setup.py installthen the installation for tesseractis taking place on 2.6rather than on 2.7.
我确实有 sudo 访问权限,但问题是:当我root以默认 python 版本登录时是 2.6,但是,当我mike以默认 python 版本登录时2.7(这是我想要的)。因此,如果我这样做,sudo python setup.py install则 for 的安装tesseract将2.6在2.7.
What can I do in this scenario? Should I change permissions on the site-packagesfolder? I'm a bit out of options...
在这种情况下我能做什么?我应该更改site-packages文件夹的权限吗?我有点别无选择...
回答by m.wasowski
try python setup.py install --user
尝试 python setup.py install --user
回答by ZZY
Maybe you can type this line as normal user:
也许你可以以普通用户的身份输入这一行:
whereis python
Assume the result is "/usr/bin/python", then:
假设结果是“/usr/bin/python”,那么:
sudo /usr/bin/python setup.py install

