Python – Fix ‘Could Not Find Platform Independent Libraries ‘ Error

python

I started using Ubuntu recently and it has been a mess. I must have manually installed something important in a directory I shouldn't have.

The other day I was deleting useless files that have accumulated on my PC. After that python keeps on giving me this message:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
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 tried some other questions that explain how to reinstall Python, but that didn't help. I also tried updating/upgrading, didn't help. I don't know what to check even to understand what I need to do to fix this.

For what it is worth, here is some output that is suspicious:

when running which python:

/home/d3ath/Enthought/Canopy_64bit/User/bin/python

python2.7 still seems to exist: ls /usr/bin/python:

python            python2.7-config  python3.4         python-config     
python2           python2-config    python3.4m        pythontex         
python2.7         python3           python3m          pythontex3

Best Answer

Ok, so the problem is resolved (for the most part).

I checked my $PATH, and found that I had appended the path /home/d3ath/Enthought/Canopy_64bit/User/bin to the start. Naturally it execute the python found in there first rather than the one in /usr/bin/ as it should. If anything the moral of the story is be careful what you do to your path.

I say "for the most part" because I don't know if whatever caused the python to fail the first time will be an import package I need to execute some of my py-code. I will have to find out and correct as I go.

Related Question