1

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?

4

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.

  • Okay, I'll try it. – Ch'en Meng Oct 30 '15 at 9:58
  • Thanks! I tried Anaconda today, and it works like a charm! – Ch'en Meng Nov 2 '15 at 9:17
  • Upvoted for Anaconda. – izaac Nov 10 '15 at 3:45
0

Do you have access to /etc/sudoers or can you tell your administrator to add this for you? You might want to add to this file username ALL = NOPASSWD : /usr/bin/apt-get , /usr/bin/aptitude, /usr/bin/whatever This will make it so you don't need sudo to access a file.

  • 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 Oct 30 '15 at 10:02
0

There is a tool for pack python with modules to anaconda-like installers - https://github.com/conda/constructor. Based on yaml config It downloading python and tools to self extracting archive which can be installed without root and internet access.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.