Python error interpretation

Hal Burgiss hal at burgiss.net
Sun Mar 15 17:24:18 UTC 2009


On Sun, Mar 15, 2009 at 12:03:53PM -0500, Chris Mohler wrote:
> On Sat, Mar 14, 2009 at 9:15 PM, Hal Burgiss <hal at burgiss.net> wrote:
> [...]
> > Could not find platform independent libraries <prefix>
> > Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
> > 'import site' failed; use -v for traceback
> 
> OK - this is bad.  I'm not sure if this is the same problem as you had
> originally, but it appears that your python cannot find *any* site
> modules.  Check your permissions:
> 
> $ ls -l /usr/lib/ | grep -i python
> lrwxrwxrwx  1 root root      19 2009-01-25 20:45 libpython2.5.so.1 ->
> libpython2.5.so.1.0
> -rw-r--r--  1 root root 1240920 2008-07-31 13:42 libpython2.5.so.1.0
> drwxr-xr-x  3 root root    4096 2008-07-02 05:49 python2.3
> drwxr-xr-x  4 root root    4096 2008-07-02 05:49 python2.4
> drwxr-xr-x 22 root root   20480 2009-01-25 20:51 python2.5
> drwxr-xr-x  9 root root    4096 2009-02-05 13:41 python-support

[root at ratt /]$ ls -l /usr/lib/ | grep -i python
lrwxrwxrwx  1 root root      19 2009-03-14 21:54 libpython2.4.so.1 -> libpython2.4.so.1.0
-rw-r--r--  1 root root 1111320 2008-07-31 14:52 libpython2.4.so.1.0
lrwxrwxrwx  1 root root      19 2009-03-14 21:54 libpython2.5.so.1 ->libpython2.5.so.1.0
-rw-r--r--  1 root root 1240920 2008-07-31 14:42 libpython2.5.so.1.0
drwxr-xr-x  3 root root    4096 2009-03-15 10:03 python-support
drwxr-xr-x  3 root root    4096 2009-03-15 10:03 python2.3
drwxr-xr-x 19 root root    4096 2009-03-14 21:54 python2.4
drwxr-xr-x 22 root root   12288 2009-03-14 21:54 python2.5

 
> Next, try:
> $ python -v -c 'import.os'

[root at ratt /]$ python -v -c 'import.os'
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/lib/python2.5/site.pyc matches /usr/lib/python2.5/site.py
import site # precompiled from /usr/lib/python2.5/site.pyc
# /usr/lib/python2.5/os.pyc matches /usr/lib/python2.5/os.py
import os # precompiled from /usr/lib/python2.5/os.pyc
import errno # builtin
import posix # builtin
# /usr/lib/python2.5/posixpath.pyc matches /usr/lib/python2.5/posixpath.py
import posixpath # precompiled from /usr/lib/python2.5/posixpath.pyc
# /usr/lib/python2.5/stat.pyc matches /usr/lib/python2.5/stat.py
import stat # precompiled from /usr/lib/python2.5/stat.pyc
# /usr/lib/python2.5/UserDict.pyc matches /usr/lib/python2.5/UserDict.py
import UserDict # precompiled from /usr/lib/python2.5/UserDict.pyc
# /usr/lib/python2.5/copy_reg.pyc matches /usr/lib/python2.5/copy_reg.py
import copy_reg # precompiled from /usr/lib/python2.5/copy_reg.pyc
# /usr/lib/python2.5/types.pyc matches /usr/lib/python2.5/types.py
import types # precompiled from /usr/lib/python2.5/types.pyc
import _types # builtin
# /usr/lib/python2.5/sitecustomize.pyc matches /usr/lib/python2.5/sitecustomize.py
import sitecustomize # precompiled from /usr/lib/python2.5/sitecustomize.pyc
# /usr/lib/python2.5/warnings.pyc matches /usr/lib/python2.5/warnings.py
import warnings # precompiled from /usr/lib/python2.5/warnings.pyc
# /usr/lib/python2.5/linecache.pyc matches /usr/lib/python2.5/linecache.py
import linecache # precompiled from /usr/lib/python2.5/linecache.pyc
import encodings # directory /usr/lib/python2.5/encodings
# /usr/lib/python2.5/encodings/__init__.pyc matches /usr/lib/python2.5/encodings/__init__.py
import encodings # precompiled from /usr/lib/python2.5/encodings/__init__.pyc
# /usr/lib/python2.5/codecs.pyc matches /usr/lib/python2.5/codecs.py
import codecs # precompiled from /usr/lib/python2.5/codecs.pyc
import _codecs # builtin
# /usr/lib/python2.5/encodings/aliases.pyc matches /usr/lib/python2.5/encodings/aliases.py
import encodings.aliases # precompiled from /usr/lib/python2.5/encodings/aliases.pyc
# /usr/lib/python2.5/encodings/utf_8.pyc matches /usr/lib/python2.5/encodings/utf_8.py
import encodings.utf_8 # precompiled from /usr/lib/python2.5/encodings/utf_8.pyc
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
  File "<string>", line 1
    import.os
          ^
SyntaxError: invalid syntax
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] site
# cleanup[1] encodings
# cleanup[1] _codecs
# cleanup[1] zipimport
# cleanup[1] warnings
# cleanup[1] encodings.utf_8
# cleanup[1] codecs
# cleanup[1] types
# cleanup[1] _types
# cleanup[1] sitecustomize
# cleanup[1] signal
# cleanup[1] linecache
# cleanup[1] posix
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[2] copy_reg
# cleanup[2] posixpath
# cleanup[2] errno
# cleanup[2] os.path
# cleanup[2] stat
# cleanup[2] UserDict
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
# cleanup ints: 7 unfreed ints in 1 out of 4 blocks
# cleanup floats
[root at ratt /]$ 

In case 'import.os' shoulda been 'import os':

[root at ratt /]$ python -v -c 'import os' 
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /usr/lib/python2.5/site.pyc matches /usr/lib/python2.5/site.py
import site # precompiled from /usr/lib/python2.5/site.pyc
# /usr/lib/python2.5/os.pyc matches /usr/lib/python2.5/os.py
import os # precompiled from /usr/lib/python2.5/os.pyc
import errno # builtin
import posix # builtin
# /usr/lib/python2.5/posixpath.pyc matches /usr/lib/python2.5/posixpath.py
import posixpath # precompiled from /usr/lib/python2.5/posixpath.pyc
# /usr/lib/python2.5/stat.pyc matches /usr/lib/python2.5/stat.py
import stat # precompiled from /usr/lib/python2.5/stat.pyc
# /usr/lib/python2.5/UserDict.pyc matches /usr/lib/python2.5/UserDict.py
import UserDict # precompiled from /usr/lib/python2.5/UserDict.pyc
# /usr/lib/python2.5/copy_reg.pyc matches /usr/lib/python2.5/copy_reg.py
import copy_reg # precompiled from /usr/lib/python2.5/copy_reg.pyc
# /usr/lib/python2.5/types.pyc matches /usr/lib/python2.5/types.py
import types # precompiled from /usr/lib/python2.5/types.pyc
import _types # builtin
# /usr/lib/python2.5/sitecustomize.pyc matches /usr/lib/python2.5/sitecustomize.py
import sitecustomize # precompiled from /usr/lib/python2.5/sitecustomize.pyc
# /usr/lib/python2.5/warnings.pyc matches /usr/lib/python2.5/warnings.py
import warnings # precompiled from /usr/lib/python2.5/warnings.pyc
# /usr/lib/python2.5/linecache.pyc matches /usr/lib/python2.5/linecache.py
import linecache # precompiled from /usr/lib/python2.5/linecache.pyc
import encodings # directory /usr/lib/python2.5/encodings
# /usr/lib/python2.5/encodings/__init__.pyc matches /usr/lib/python2.5/encodings/__init__.py
import encodings # precompiled from /usr/lib/python2.5/encodings/__init__.pyc
# /usr/lib/python2.5/codecs.pyc matches /usr/lib/python2.5/codecs.py
import codecs # precompiled from /usr/lib/python2.5/codecs.pyc
import _codecs # builtin
# /usr/lib/python2.5/encodings/aliases.pyc matches /usr/lib/python2.5/encodings/aliases.py
import encodings.aliases # precompiled from /usr/lib/python2.5/encodings/aliases.pyc
# /usr/lib/python2.5/encodings/utf_8.pyc matches /usr/lib/python2.5/encodings/utf_8.py
import encodings.utf_8 # precompiled from /usr/lib/python2.5/encodings/utf_8.pyc
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) 
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
# clear __builtin__._
# clear sys.path
# clear sys.argv
# clear sys.ps1
# clear sys.ps2
# clear sys.exitfunc
# clear sys.exc_type
# clear sys.exc_value
# clear sys.exc_traceback
# clear sys.last_type
# clear sys.last_value
# clear sys.last_traceback
# clear sys.path_hooks
# clear sys.path_importer_cache
# clear sys.meta_path
# restore sys.stdin
# restore sys.stdout
# restore sys.stderr
# cleanup __main__
# cleanup[1] site
# cleanup[1] encodings
# cleanup[1] _codecs
# cleanup[1] zipimport
# cleanup[1] warnings
# cleanup[1] encodings.utf_8
# cleanup[1] codecs
# cleanup[1] types
# cleanup[1] _types
# cleanup[1] sitecustomize
# cleanup[1] signal
# cleanup[1] linecache
# cleanup[1] posix
# cleanup[1] encodings.aliases
# cleanup[1] exceptions
# cleanup[2] copy_reg
# cleanup[2] posixpath
# cleanup[2] errno
# cleanup[2] os.path
# cleanup[2] stat
# cleanup[2] UserDict
# cleanup[2] os
# cleanup sys
# cleanup __builtin__
# cleanup ints: 7 unfreed ints in 1 out of 4 blocks
# cleanup floats


> As a shot in the dark - do you have plenty of free disk space?

Yea, basically a new installation:

[root at ratt /]$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             33539080   1589940  30245452   5% /
varrun                  517580        56    517524   1% /var/run
varlock                 517580         0    517580   0% /var/lock
udev                    517580        44    517536   1% /dev
devshm                  517580         0    517580   0% /dev/shm
 
> I do love me some Python, but it can be frustrating when it's not
> working properly - esp when system tools depend on it!

It seems to me that while apt is a great tool, when one has to re-install
something, it tends to want a little pain. 

This system had been CentOS at one point, then went to 6.06, and now 8.04, so
there may be some buried cruft (I did none of those installations personally). I
had some wierd Apache and php package related issues too (fixed with a
purge/reinstall). 

Thanks for the help.

-- 
Hal





More information about the ubuntu-users mailing list