6

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
Community
  • 1
  • 1
Bostone
  • 36,858
  • 39
  • 167
  • 227

1 Answers1

1

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... :-)

Community
  • 1
  • 1
serv-inc
  • 35,772
  • 9
  • 166
  • 188
  • Indeed all "eggs" are missing from the regular user sys.path. Thank you for your reply I was afraid that the bounty will go unclaimed :) – Bostone Aug 12 '16 at 17:17
  • @Bostone: that had happened to one of my bounties once and it was a disappointing feeling :). Did it help you enough, or do you require further help? – serv-inc Aug 12 '16 at 19:01
  • I'm in the process of determining that ;) – Bostone Aug 12 '16 at 19:53
  • It's crazy that 2.7 is not really supported on SLES 11. Thanks for your help, enjoy the bounty – Bostone Aug 13 '16 at 01:33
  • @Bostone: You're welcome. Good that it worked out ok. Thanks for the bounty. And for sure, 2.7 should be well-supported, but ... – serv-inc Aug 13 '16 at 12:08
  • Sorry to revisit this but collecting path from root user and putting it into PYTHONPATH nor using sys.path.append fixed the problem. Still when I try `import yaml` I get `File "", line 1, in ImportError: No module named yaml` error – Bostone Aug 17 '16 at 15:20
  • And no luck running pip or easy_install – Bostone Aug 17 '16 at 15:31
  • as a Python newbie I'm not sure if I'm setting the PYTHONPATH correctly so I put the whole thing as P.S. into the original question – Bostone Aug 17 '16 at 16:34
  • @Bostone: PYTHONPATH just needs to contain additional modules. Try again as `export PYTHONPATH=/opt/python2.7/lib/python27.zip...` and post the results if it does not work, together with `sys.path` and `PYTHONPATH` befor and after. See also http://stackoverflow.com/questions/1001851/pythonpath-ignored. – serv-inc Aug 21 '16 at 11:03