我正在尝试以用户 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模板网!
python:不同包下同名的两个模块和类python: Two modules and classes with the same name under different packages(python:不同包下同名的两个模块和类)
配置 Python 以使用站点包的其他位置Configuring Python to use additional locations for site-packages(配置 Python 以使用站点包的其他位置)
如何在不重复导入顶级名称的情况下构造python包How to structure python packages without repeating top level name for import(如何在不重复导入顶级名称的情况下构造python包)
在 OpenShift 上安装 python 包Install python packages on OpenShift(在 OpenShift 上安装 python 包)
如何刷新 sys.path?How to refresh sys.path?(如何刷新 sys.path?)
分发带有已编译动态共享库的 Python 包Distribute a Python package with a compiled dynamic shared library(分发带有已编译动态共享库的 Python 包)