<< Python problem: ImportError: No module named site >>


I had program called CIF2CELL running well.

After updating my system (OpenSUSE Tumbleweed) I am getting the subject error:
ImportError: No module named site

I removed the CIF2CELL folder and did a clean install.

Some infos:

In my .bashrc:

export PYTHONPATH=/software/cif2cell/lib/python2.7/site-packages/:$PYTHONPATH
export PYTHONHOME=/usr

Some outputs from python checks:

python -i
>>> import site; site.getsitepackages()
'/usr/lib64/python2.7/site-packages', '/usr/lib64/site-python', '/usr/lib/python2.7/site-packages', '/usr/lib/site-python']


python -m site
sys.path = 
USER_BASE: '/home/hatuey/.local' (exists)
USER_SITE: '/home/hatuey/.local/lib/python2.7/site-packages' (doesn't exist)

I appreciate any help solving this issue.



I suspect that you installed your site library as a subdirectory of your $HOME folder.
When you do that, it can be found by your Python app only when you’re logged in as that User or using sudo to elevate permissions…
If you instead open a root console with “su” your $HOME path will point to /root/ instead of your current home directory…

Or the scenarios I described above can be reversed.

It’s why (besides security implications) I don’t recommend the common practice of installing libraries in your $HOME folder, instead recommending a root subdirectory like /opt/.