How to install Python on CentOS without root privileges?

12,771

You can run Python + tools from your home directory.
Go to https://www.continuum.io/downloads to get Anaconda which has all of these packages listed here: http://docs.continuum.io/anaconda/pkg-docs including libFFI, openssl, and zlib.

Once you install, restart your terminal and wallah. (the $PATH gets changed for you and you alone so your system's software is unaffected, and no need for emails to your administrator.)

If you need other packages that you didn't list here, you can use conda, pip, or setup.py to get more.

Go forth and be awesome.

Share:
12,771

Related videos on Youtube

Ch'en Meng
Author by

Ch'en Meng

A LaTeX user and an English learner. The author of the xprintlen and the sduthesis package. A committer of ctex-kit project, related packages: ctex, xeCJK, etc.

Updated on September 18, 2022

Comments

  • Ch'en Meng
    Ch'en Meng over 1 year

    For some reasons, I need to install Python on CentOS without root privileges. Since without root, one cannot use yum to install packages, so I tried

    ./configure --prefix=$HOME/tools/python
    make
    make install
    

    and it did work. However, when I was trying to install setuptools for it, by

    wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py -O - | python - --user --insecure
    

    Python complained that

    urllib2.URLError: <urlopen error unknown url type: https>
    

    It seems that Python was not compailed well with openssl lib. So I downloaded setuptools from its website, un-archived it, and then run

    python setup.py install
    

    and got

    RuntimeError: Compression requires the (missing) zlib module
    

    Hence, re-compile and reinstall Python is needed. This time, before I configure Python, I installed zlib, openssl and libffi manually, by adding --prefix="$HOME/tools/foo", since I have no privileges to write in /usr/foo/bar.

    After that, I tried to configure Python with flags, like --with-zlib=$HOME/tools/zlib. Unfortunately again, Python showed a line on the screen, that these flags are unknown. Then I tried to modify /Modules/Setup.dist, with expectation that I could specify the path to those libs, by uncomment the following lines:

    #SSL=/home/foo/tools/openssl-1.0.0s
    #_ssl _ssl.c \
    #       -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    #       -L$(SSL)/lib -lssl -lcrypto
    ......
    #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz 
    

    This time, things got even worse that compiling stopped by

    ./Modules/zlibmodule.c:8:18: error: zlib.h: No such file or directory
    

    I searched the whole web, and found nothing. Hence, I come here and raise the question: how to install Python with zlib, openssl and libffi etc., on a CentOS, without root privileges?

  • Ch'en Meng
    Ch'en Meng over 8 years
    Okay, I'll try it.
  • Ch'en Meng
    Ch'en Meng over 8 years
    Yes, asking system admin for sudo privilege is indeed a solution. However, for me, I can only ask for this for a while, and after I install Python, the admin will cancel my privilege. Hence, asking temp privilege cannot solve this once and for all. : (
  • Ch'en Meng
    Ch'en Meng over 8 years
    Thanks! I tried Anaconda today, and it works like a charm!
  • izaac
    izaac over 8 years
    Upvoted for Anaconda.