Search code examples
pythonsetuptools

Installing a python package/tool by a non root user


(1) I have to install one python package (HTSeq) but i dont have root privileges.

The package need python 2.4 or latest version. We have python 2.3 on our cluster.

Thus I installed python 2.7 on my one local directory using

./configure --prefix=/home/amit/tools/localpython 
make 
make install

(2) The package also requires numpy : so I also installed it on my local directory using:

/home/amit/tools/localpython/bin/python2.7 setup.py install --home=/home/amit/tools/localnumpy 

and done

>>> sys.path.append("/home/amit/tools/localnumpy/lib/")

(3) I downloaded the tar file of HTSeq (Which i want to download) and run

/home/amit/tools/localpython/bin/python2.7 setup.py install --home=/home/amit/tools/localhtseq

it is throwing following error:

Could not import 'setuptools',
falling back to 'distutils'.
Setup script for HTSeq: Failed to import 'numpy'.
Please install numpy and then try again to install HTSeq.

Kindly provide me some hint on how to get over it

Thanks in advance


Solution

  • Setuptools is another requirement which you need to install that package.

    One option is to use virtualenv to create a contained python environment. This can be made everywhere and is owned by the user who creates it.

    To install virtualenv without admin rights (from this answer):

    Download tar.gz of the latest version of virtualenv. Unpack it. You don't even need to install it, just run virtualenv.py, for example:

    wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.7.1.2.tar.gz
    tar -xzf virtualenv-1.7.1.2.tar.gz
    /home/amit/tools/localpython/bin/python2.7 virtualenv-1.7.1.2/virtualenv.py env
    
    env/bin/pip install HTSeq
    env/bin/pip install numpy
    

    Now run your script using the python binary in the virtual environment:

    env/bin/python myscript.py