By admin on

Custom Python

Build python from source without root access

You can get rid of root access by doing the installation into a directory you have write access


These are steps when you are on shared hosting environment and need to install & compile Python from source and then create venv from your Python version.

For Python 2.7.9 you would do something along these lines:


mkdir ~/src
wget http://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
tar -zxvf Python-2.7.9.tgz
cd Python-2.7.9
mkdir ~/.localpython
./configure --prefix=$HOME/.localpython
make
make install

Creating a virtual env

cd ~/src
wget https://pypi.python.org/packages/5c/79/5dae7494b9f5ed061cff9a8ab8d6e1f02db352f3facf907d9eb614fb80e9/virtualenv-15.0.2.tar.gz#md5=0ed59863994daf1292827ffdbba80a63
tar -zxvf virtualenv-15.0.2.tar.gz
cd virtualenv-15.0.2/
~/.localpython/bin/python setup.py install
virtualenv ve -p $HOME/.localpython/bin/python2.7
source ve/bin/activate

Naturally this can be applicable to any situation where you want to replicate the exact environment you work and deploy on.


0 comments

Write a response
Publish