Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to install Python without sudo access

I extracted, configured and used make for the installation package in my server.

However, I could not use make install. I get the error

[~/wepapps/python/Python-2.6.1]# make install /usr/bin/install -c python /usr/local/bin/python2.6 /usr/bin/install: cannot create regular file `/usr/local/bin/python2.6': Permission denied make: *** [altbininstall] Error 1 

I run the folder with

chmod +x Python-2.6.1 

I get still the same error.

How can I run make install without sudo access?

like image 372
Léo Léopold Hertz 준영 Avatar asked Mar 07 '09 23:03

Léo Léopold Hertz 준영


People also ask

Do you need admin rights to install Python packages?

To install Python packages (“eggs”) from the Python language's package manager pip, follow our instructions below. This can be done without Administrator access in a per-user, per-project clean manner with virtualenv.


2 Answers

As of year 2020, pyenv is the best choice for installing Python without sudo permission, supposing the system has necessary build dependencies.

# Install pyenv $ curl https://pyenv.run | bash  # Follow the instruction to modify ~/.bashrc  # Install the latest Python from source code $ pyenv install 3.8.3  # Check installed Python versions $ pyenv versions  # Switch Python version $ pyenv global 3.8.3  # Check where Python is actually installed $ pyenv prefix /home/admin/.pyenv/versions/3.8.3  # Check the current Python version $ python -V Python 3.8.3 
like image 28
leoly Avatar answered Oct 11 '22 15:10

leoly


How can I install to a path under my home directory?

mkdir /home/masi/.local  cd Python-2.6.1 make clean ./configure --prefix=/home/masi/.local make make install 

Then run using:

/home/masi/.local/bin/python 

Similarly if you have scripts (eg. CGI) that require your own user version of Python you have to tell them explicitly:

#!/home/masi/.local/bin/python 

instead of using the default system Python which “#!/usr/bin/env python” will choose.

You can alter your PATH setting to make just typing “python” from the console run that version, but it won't help for web apps being run under a different user.

If you compile something that links to Python (eg. mod_wsgi) you have to tell it where to find your Python or it will use the system one instead. This is often done something like:

./configure --prefix=/home/masi/.local --with-python=/home/masi/.local 

For other setup.py-based extensions like MySQLdb you simply have to run the setup.py script with the correct version of Python:

/home/masi/.local/bin/python setup.py install 
like image 99
bobince Avatar answered Oct 11 '22 14:10

bobince