3

I'm new to Linux/CentOS and I'm not having the most fun using it. I was developing something locally on my Mac using python 2.7 when I ran it on the server I ran into issues which I put down to being the outdated version of Python (2.4.3) I then updated it, which wasn't a very good idea. I built it from source and then ran into issues, Yum and other modules disappeared.

I'm not back using Python 2.4.3 but I still don't have Yum back.

[root@issues ~]# yum Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:]

'import site' failed; use -v for traceback There was a problem importing one of the Python modules required to run yum. The error leading to this problem was:

No module named yum

Please install a package which provides this module, or verify that the module is installed correctly.

It's possible that the above module doesn't match the current version of Python, which is: 2.4.3 (#1, Jun 18 2012, 08:55:31) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)]

If you cannot solve this problem yourself, please go to the yum faq at: http://wiki.linux.duke.edu/YumFaq

Searching loads of forums everyone says that it's because of a different version of Python, this is no longer the case for me, I think it's something to do with Yum being mapped to a different directory.

I found this command somewhere else and ran this:

[root@issues ~]# rpm -V python

missing /usr/bin/python2

missing /usr/bin/python2.4

Does anyone know what to do or where to go for help? I really need to get this fixed as soon as possible!

Thanks

Actually just to add, If I run python I get this output.

[root@issues ~]# python

Could not find platform independent libraries

Could not find platform dependent libraries

Consider setting $PYTHONHOME to [:]

'import site' failed; use -v for traceback

Python 2.4.3 (#1, Jun 18 2012, 08:55:31)

[GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>

Rich
  • 154
  • 2
  • 11

1 Answers1

3

Yes on Linux systems, it is not a good idea to upgrade default python which is 2.4.x version and Linux package management and many other tools require it to function correctly. It is always better to install other python versions separately and use it directly (like: /usr/bin/python2.7)

Python executable itself is not working correctly as it is not able to load default module 'site' during start-up.

The python installation is broken.

Since you can not use "Yum" or "RPM" to bootstrap your packages, I suggest that you use your "OS" installation CD or ISO image to install the rpm/yum packages directly. It will fix the python installation as dependency.

I had gone through this issue and after various trial, this was only way I could fix it.

[Edit:]

See: Python 2.x multiple version issues regarding PYTHONPATH

Also the error is that it is not able to find the package directory.

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

See the paths that I have. Check out the path of packages and can you set "PYTHONHOME".

# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/lib64/python2.4/site.pyc matches /usr/lib64/python2.4/site.py
import site # precompiled from /usr/lib64/python2.4/site.pyc
# /usr/lib64/python2.4/os.pyc matches /usr/lib64/python2.4/os.py
import os # precompiled from /usr/lib64/python2.4/os.pyc

If you are not able to locate similar package location, can you use RPM to directly install python2.4 again

rpm --force -hUv url_for_python_rpm
Community
  • 1
  • 1
pyfunc
  • 65,343
  • 15
  • 148
  • 136
  • Thanks for your help, Unfortunately this isn't an options as it's a remote server. RPM is still working OK though. If I run rpm I get no errors? – Rich Jun 23 '12 at 16:34
  • 1
    @Rich: Can you try running - python -v. There seems to be an issue in importing packages. This is due to the fact that 'site' package is required to do that and it is not able to. – pyfunc Jun 23 '12 at 16:48
  • Is there an easy way to change this? – Rich Jun 23 '12 at 16:59
  • Wait. I'm such an idiot, that above response was run locally, on the server I get: http://pastebin.com/SmPN2h9T – Rich Jun 23 '12 at 17:05
  • Ok I've now modified PYTHONPATH and PYTHONHOME I am no longer getting the YUM error but instead 'No module named OS' I set both paths to /usr/lib/python2.4/site-packages – Rich Jun 23 '12 at 17:18
  • site-packages is meant for external packages. default packgaes are one directory above – pyfunc Jun 23 '12 at 17:23
  • And looking in there I find no files like os.py. I ran 'find / -name os.py' and it found it in a python2.7 file I'm no longer using. – Rich Jun 23 '12 at 17:31
  • 1
    @Rich: You really need to force re-install python2.4 with rpms – pyfunc Jun 23 '12 at 17:35
  • thanks, I did this and then ran into more issues, Spent about 4 hours this morning but now got everything working. Thanks for your help! – Rich Jun 24 '12 at 12:18
  • I was able to fix with the help of this answer. I still had `python2.4` in `/usr/bin`, so I changed a symlink to point back to 2.4 instead of 2.7. Now yum works. – Jess Jul 31 '13 at 12:42