問題描述
我正在嘗試以用戶 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
但是,當(dāng)我執(zhí)行 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 訪問權(quán)限,但問題是:當(dāng)我以 root
身份登錄時,默認(rèn) python 版本是 2.6,但是,當(dāng)我以 mike
身份登錄時,默認(rèn) python版本是 2.7
(這是我想要的).因此,如果我執(zhí)行 sudo python setup.py install
那么 tesseract
的安裝將發(fā)生在 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
.
在這種情況下我能做什么?我應(yīng)該更改 site-packages
文件夾的權(quán)限嗎?我有點沒辦法了……
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/您沒有權(quán)限的地方(除非您使用 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).
這篇關(guān)于如何在沒有 sudo 的情況下為 Python 安裝包時避免權(quán)限被拒絕的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!