我正在尝试以用户 mike
的身份安装 Python 的 tesseract
包装器,以便我可以 import tesseract
.我在这里遵循指南 https://code.google.com/p/python-tesseract/wiki/HowToCompilePythonTesseractForCentos
I am trying to install the tesseract
wrapper for python as user mike
so that I can import tesseract
. I'm following the guide here https://code.google.com/p/python-tesseract/wiki/HowToCompilePythonTesseractForCentos
但是,当我执行 python setup.py install
我收到以下错误:
[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/
我确实有 sudo 访问权限,但问题是:当我以 root
身份登录时,默认 python 版本是 2.6,但是,当我以 mike
身份登录时,默认 python版本是 2.7
(这是我想要的).因此,如果我执行 sudo python setup.py install
那么 tesseract
的安装将发生在 2.6
而不是 2.7代码>.
I do have sudo access but here is the problem: When I login as root
the default python version is 2.6, however, when I login as mike
the default python version is 2.7
(this is the one I want). So if I do sudo python setup.py install
then the installation for tesseract
is taking place on 2.6
rather than on 2.7
.
在这种情况下我能做什么?我应该更改 site-packages
文件夹的权限吗?我有点没办法了……
What can I do in this scenario? Should I change permissions on the site-packages
folder? I'm a bit out of options...
试试 python setup.py install --user
这会将软件包安装到 /home/your_user/.local/lib/pythonX.X/site-packages/ 而不是 /usr/local/lib/您没有权限的地方(除非您使用 sudo).
This will install the package on /home/your_user/.local/lib/pythonX.X/site-packages/ instead of /usr/local/lib/ where you don't have permissions (unless you use sudo).
这篇关于如何在没有 sudo 的情况下为 Python 安装包时避免权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!