SystemError: _PyImport_FixupExtension: module _types not loaded

usenet1 at ingfamily.net usenet1 at ingfamily.net
Thu Feb 15 13:42:51 EST 2007


On Feb 12, 2:25 pm, "Gabriel Genellina" <gagsl... at yahoo.com.ar> wrote:
> En Mon, 12 Feb 2007 15:44:36 -0300, <usen... at ingfamily.net> escribió:
>
> > I'm trying to write some "C" code that will run a python script that
> > can in turn call some "C" functions.  However I'm having a problem
> > getting started because although I can run a script from the python
> > ide that imports ctypes, when I execute that 'import ctypes' code from
> > the "C" code I get the following error:
>
> > 'import site' failed; use -v for traceback
>
> You have to fix this first. Probably you can't import anything, not just  
> ctypes.
> Quoting myself from a similar problem:
>
> Try this:
> PyRun_SimpleString("import sys; print sys.path");
> to see where Python expects to find its library (or call the Py_GetPath  
> function).
> You may need to call Py_SetProgramName (before Py_Initialize) so it can  
> find where the standard library resides.
> At least for testing purposes, you can copy your executable into the same  
> directory where Python is installed.
>
> --
> Gabriel Genellina

This is what I get:

'import site' failed; use -v for traceback
['c:\\temp\\pytest\\Debug\\python25_d.zip', 'C:\\Python25\\Lib', 'C:\
\Python25\\DLLs', 'C:\\Python25\\Lib\\lib-tk', '', 'c:\\temp\\pytest\
\Debug']

In fact, the 'import site' failed; use -v for traceback happens when I
call the Py_Initialize().

As can be seen from the output, the import sys; and print sys.path
works.  I also added Py_SetProgramName(argv[0]) before calling
PyInitialize() but there was no change.

Thanks,
Steve




More information about the Python-list mailing list