To install and use Django 1.4.1 without sudo access

Posted on

Problem :

I want to install this software to a server where I have no sudo access.
They have Django 1.2.x installed there, but the software needs Django 1.4.1.
The server has the adapter between Python and PostgreSQL database, psycopg2.
Details of the server

Linux 3.2.46-grbfs #1 SMP Wed Jun 5 19:48:35 EEST 2013 x86_64
HP DL 360 G7: 2x6-core Xeon @ 3,07 GHz, 144 GB ECC

I run the script in Python so I do not need change the script executable

python setup.py install

and everything goes fine until I get the error on the last line

copying django/templatetags/l10n.py -> build/lib.linux-x86_64-2.6/django/templatetags
running build_scripts
creating build/scripts-2.6
copying and adjusting django/bin/django-admin.py -> build/scripts-2.6
changing mode of build/scripts-2.6/django-admin.py from 644 to 755
running install_lib
creating /usr/local/lib/python2.6/dist-packages/django
error: could not create '/usr/local/lib/python2.6/dist-packages/django': Permission denied

How can you solve this problem without sudo access?

Solution :

Have a look at virtualenv. With that you can create separate Python environments.

Extension to Roland’s answer.
Yes. I have done this:

virtualenv --python=pythonX env
. env/bin/activate
pip install -r requirements.txt

but then I got stucked here.

Use pip to install Django 1.4.1 in a different directory (e.g. /opt) and add that to your $PATH

pip install --install-option="--prefix=/opt" Django==1.4.1

Leave a Reply

Your email address will not be published.