PyImport_ImportModule/embedding: surprising behaviors

David Abrahams dave at boost-consulting.com
Wed Mar 21 01:02:20 CET 2007


I'm seeing highly surprising (and different!) behaviors of
PyImport_ImportModule on Linux and Windows when used in a program with
python embedding.

On Linux, when attempting to import a module xxx that's in the current
directory, I get

  ImportError: No module named xxx

I can work around the problem by setting 

  PYTHONPATH=.

On Windows, I get:

  'import site' failed; use -v for traceback

I can work around the problem by setting PYTHONPATH to point to the
python library directory:

  set PYTHONPATH=c:\Python25\Lib

I was under the impression that both the current directory *and* the
python library directory were already, automatically, in sys.path, so
I'm really surprised to see this.  Am I doing something wrong, or is
this simply the expected behavior (and if so, where is it documented)?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Python-list mailing list