Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to avoid Permission denied while installing package for Python without sudo

Tags:

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

However, when I execute 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 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.

What can I do in this scenario? Should I change permissions on the site-packages folder? I'm a bit out of options...

like image 931
Anthony Avatar asked Mar 21 '14 06:03

Anthony


People also ask

How do I install Python packages without root access?

Use the --user option to install Python modules without root access, e.g. pip install requests --user . The --user option installs the package in the user's home directory and helps with permission issues.

Do I need admin rights to install Python packages?

Many people don't know that even if you don't have local admin access you may still be able to install Python using the official installer from https://python.org. If this works for you then this will be the simplest way to get Python onto your PC.

Can install pip permission denied?

When attempting to install or upgrade packages using "pip install", you receive a permission denied error. It's possible to install/upgrade packages in a workspace session, but you need to include the --user flag to avoid the permissions error. However, this installation will not persist from run to run.


1 Answers

try python setup.py install --user

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).

like image 112
m.wasowski Avatar answered Sep 20 '22 12:09

m.wasowski