[Python-Dev] Embedded python on Win2K, import failures

Harri Pasanen harri.pasanen@trema.com
Tue, 22 Apr 2003 14:47:02 +0200

On Sunday 13 April 2003 15:05, Mark Hammond wrote:
> > Did you try -v, as
> >
> > > 'import site' failed; use -v for traceback
> >
> > suggested?
> Yep. as I said:
> > > Running with "-v" shows:
> Note that as I mentioned, this is only if you move away _sre.pyd. 
> The original report was almost certainly a simple import error.

I was away the past week, so excuse my delayed response.

Ok, I found the problem, it is just a difference in the way Linux and 
Windows versions are built, but the failure mode could arguably be a 

_sre.pyd is a separate module in windows, while on linux it is part of 
the whole lib.  (libpython23.a, libpython23.so).

I was running the python from the build tree, and PCbuild was not part 
of the sys.path for the embedded python.

When running with the interactive python, in the style 
../../PCbuild/python.exe, the sys.path implicitly gets the PCbuild 
directory, _sre.pyd is found and everything works.

So when everything is configured and installed properly, everything 

The bug here is, that when _sre.pyd is not found from sys.path, and 
I'm running the embedded python.  I'm not seeing any import errors, 
things just silently fail. At runtime "import re" goes though without 
a problem, but the resulting module is invalid, which is only noticed 
when the module is first time used.   So I had no idea that _sre 
module was not being found, or that it was even required.

Does this merit a bug at sf?  

Another thing, assuming I would get an import error from the embedded 
python, how do I enable the "use -v for traceback" for an it?  Is 
there a function call I can add for the same effect?