Linux – Python error In linux

linuxpython

I removed the default python install from my linux using rpm command without removing the dependencies, I was trying to install 2.7 manually, which wasn't working out that is whay I thouht may be it was because of conflict, but it messed up, I am getting this error when I try to evoke python after reinstalling 2.6 again

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting `$PYTHONHOME` to `<prefix>[:<exec_prefix>]`
ImportError: No module named site

I have tried setting PYTHONHOME and PYTHONPATH but it doesn't work so well, I get the last error ImportError: No module named site and also other programs like yum don't function. What should I do? Also when I installed 2.7 I used --libdir=/usr/lib64 to configure it.

My system is 64 bit, and I really need it back the way it was, what should I do? can it be solved by using linux rescue? Any help will be appreciated. I spent hours online reading the solutions from other users facing the same problem but it didn't help.

Using the whereis command I found these:

python: /usr/bin/python /usr/bin/python2.6 /usr/bin/python2.6-config /usr/lib/python2.3 /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python /usr/local/bin/python2.7-config /usr/local/bin/python3.2m /usr/local/bin/python3.2 /usr/local/bin/python3.2m-config /usr/local/bin/python2.7 /usr/local/bin/python3.2-config /usr/local/lib/python3.2 /usr/include/python2.6 /opt/python2.7/bin/python2.7-config /opt/python2.7/bin/python2.7 /usr/share/man/man1/python.1.gz

What should I do? I can't live invoking python manually all the time when I am programming.

I am using Scientific Linux 6.3

Best Answer

I had this exact error using CentOS 6.7 (Final) on a 64 bit system. I had to change two paths in order for python to work again. (Specifically gdb was giving me the same error you were getting.)

export PYTHONHOME=/usr/lib64/python2.6/
export PYTHONPATH=/usr/lib64/python2.6/

Other answers were saying to only modify one of those variables or use the non-64bit lib folder. But this was the only method that worked for me. Hopefully this can help someone else. In your case you might want to use the python2.7 folder however. But you can use python2.6 to get back to a working system at least.

Related Question