Problems importing a module (as a shared lib) from the current working directory

John Copella jcopella at cfl.rr.com
Sat May 5 02:56:52 EDT 2001


I'm using Python 2.1 on AIX 4.2, and I'm having some trouble with the import
statement.

If I attempt to import a module (implemented as a shared lib) that resides
in the same directory where I am running the interpreter, I get an
ImportError exception.  However, if I then change directories (doesn't
matter where), I can import the module fine, as long as sys.path is set
correctly.  Alternatively, I can move the .so to some other location in
sys.path, and things are fine.

Consider the following transcript:

[269] > setenv PYTHONPATH `pwd`
[270] > ls -l *.so
-rwxrwxr-x   1 xxxxxxxx  usr       17587 May 05 01:09 examplecmodule.so
[271] > python -c 'import examplec'
Traceback (most recent call last):
  File "<string>", line 1, in ?
ImportError: from module examplecmodule.so No such file or directory
[272] > cd ..
[273] > python -c 'import examplec'
[274] > #note no error occurs

It's not really a show-stopper, but it's one of those things that makes me
feel uneasy, because I thought I had a good handle on import semantics.  Any
ideas as to what's going on here?

JC





More information about the Python-list mailing list