Check sys.path to make sure your python interpreter is looking in the correct directories. It should look something like this (not necessarily identical):
>>> import sys >>> sys.path ['', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/pymodules/python2.6']
EDIT: with updated information on the question that this is an installation of unknown origin on a limited device, assuming that unnecessary modules were removed to save space, it makes sense. However, for the record I’ll talk about another, perhaps more common scenario, when the modules cannot be found: when there are problems with file permissions. For instance:
$ python -c 'import contextlib; print(contextlib.__file__)' /usr/lib/python2.6/contextlib.pyc $ ls -l /usr/lib/python2.6/contextlib.py* -rw-r--r-- 1 root root 4136 Dec 26 16:42 /usr/lib/python2.6/contextlib.py -rw-r--r-- 1 root root 4127 Jan 1 21:45 /usr/lib/python2.6/contextlib.pyc $ sudo chmod go-r /usr/lib/python2.6/contextlib.py* $ python -c 'import contextlib; print(contextlib.__file__)' Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named contextlib
Particularly with custom installations, import problems due to file permissions and content issues are some of the easiest things to check and, as a rule, to fix.
Ned deily
source share