Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Python 2.7 for all users on SLES 11

I installed Python 2.7 on SLES 11 box that previously was running Python 2.6. To do so I used a script described in this post and run it as a root user. Everything went well but when it was done I discovered few issues:

  1. No symbolic links were created and no path updated so I had to manually update the path to link to the new installation bin directory /opt/python2.7/bin
  2. Everything runs good until I switch from root to the normal user at which point Python shell runs but some modules I installed such as PyYAML are missing. Again, these are OK when I run Python as root
  3. As a regular user I'm not able to run pip, easy_install and wheel. For pip I get ImportError: No module named pkg_resources

P.S. Following @user suggestion I tried adding the following path taken from sys.path of the root user to .bashrc which did not fix the problem

export PYTHONPATH=$PYTHONPATH:/opt/python2.7/lib/python27.zip:/opt/python2.7/lib/python2.7:/opt/python2.7/lib/python2.7/plat-linux2:/opt/python2.7/lib/python2.7/lib-tk:/opt/python2.7/lib/python2.7/lib-old:/opt/python2.7/lib/python2.7/lib-dynload:/opt/python2.7/lib/python2.7/site-packages:/opt/python2.7/lib/python2.7/site-packages/PyYAML-3.11-py2.7-linux-x86_64.egg:/opt/python2.7/lib/python2.7/site-packages/pexpect-4.2.0-py2.7.egg:/opt/python2.7/lib/python2.7/site-packages/ptyprocess-0.5.1-py2.7.egg
like image 257
Bostone Avatar asked Aug 03 '16 17:08

Bostone


1 Answers

Credible / official sources: no reply from official forum. Apart from the SO-link you mentioned, there is also https://unix.stackexchange.com/questions/7644/how-to-do-a-binary-install-of-python-2-7-on-suse-linux-enterprise-server-11, which sketches the way to do it described in Installing Python 2.7 on SLES 11 (SO is not official, is it? ;-)

Concerning your problem: both 2. and 3. might be caused by elements lacking in sys.path.

To test this, type

import sys; sys.path

both in user and root python and check for differences. These need to be merged. Try using PYTHONPATH first to test this, but be aware that there are different methods how to adjust sys.path.

If you just need to fix this for normal (non-daemon) users, adjusting the system-wide bash profile would be an easy solution.

(Any questions/feedback is welcome... :-)

like image 135
serv-inc Avatar answered Sep 19 '22 01:09

serv-inc