linux - To install and use Django 1.4.1 without sudo access

05
2014-04
  • Masi

    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?

  • Answers
  • Roland Smith

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

  • Area 51

    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.


  • Related Question

    ubuntu - Python Module: Trouble Installing Bitarray
  • Dan

    I'm not sure why I am having trouble installing the Python Module Bitarray on my Ubuntu 8.10 machine.

    dan@Tower:~/py$ tar xzf bitarray-0.3.5.tar.gz
    dan@Tower:~/py$ cd bitarray-0.3.5
    dan@Tower:~/py/bitarray-0.3.5$
    dan@Tower:~/py/bitarray-0.3.5$ python setup.py install
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-i686-2.5
    creating build/lib.linux-i686-2.5/bitarray
    copying bitarray/test_bitarray.py -> build/lib.linux-i686-2.5/bitarray
    copying bitarray/__init__.py -> build/lib.linux-i686-2.5/bitarray
    running build_ext
    building 'bitarray._bitarray' extension
    creating build/temp.linux-i686-2.5
    creating build/temp.linux-i686-2.5/bitarray
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.5 -c bitarray/_bitarray.c -o build/te
    mp.linux-i686-2.5/bitarray/_bitarray.o
    gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-i686-2.5/bitarray/_bitarray.o -o build/lib.linux-i686-2.5/bitarray/_bitarray.so
    running install_lib
    creating /usr/lib/python2.5/site-packages/bitarray
    error: could not create '/usr/lib/python2.5/site-packages/bitarray': Permission denied
    
    
    dan@Tower:~/py/bitarray-0.3.5$ sudo python setup.py install
    [sudo] password for dan: 
    running install
    running build
    running build_py
    running build_ext
    running install_lib
    creating /usr/lib/python2.5/site-packages/bitarray
    copying build/lib.linux-i686-2.5/bitarray/_bitarray.so -> /usr/lib/python2.5/site-packages/bitarray
    copying build/lib.linux-i686-2.5/bitarray/test_bitarray.py -> /usr/lib/python2.5/site-packages/bitarray
    copying build/lib.linux-i686-2.5/bitarray/__init__.py -> /usr/lib/python2.5/site-packages/bitarray
    byte-compiling /usr/lib/python2.5/site-packages/bitarray/test_bitarray.py to test_bitarray.pyc
    byte-compiling /usr/lib/python2.5/site-packages/bitarray/__init__.py to __init__.pyc
    running install_egg_info
    Writing /usr/lib/python2.5/site-packages/bitarray-0.3.5.egg-info
    
    
    dan@Tower:~/py/bitarray-0.3.5$ python -c 'import bitarray; bitarray.test()'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "bitarray/__init__.py", line 13, in <module>
        from _bitarray import _bitarray, bits2bytes, _sysinfo
    ImportError: No module named _bitarray
    

  • Related Answers
  • Lukáš Lalinský

    The module is installed correctly, but it tries to import the local version if you are in ~/py/bitarray-0.3.5. This doesn't work because you don't have _bitarray.so in the source code tree (you would need python build_ext -i to make it work). Just go to some other directory and run python from there, it will work.