问题描述
我试图以用户 mike
的身份为python安装 tesseract
包装程序,以便我可以导入tesseract
。我在这里遵循指南
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-用户
这会将软件包安装在 /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安装软件包时被拒绝的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!