SystemError: _PyImport_FixupExtension: module _types not loaded

usenet1 at ingfamily.net usenet1 at ingfamily.net
Mon Feb 12 13:44:36 EST 2007


I'm a newbie with hopefully an easy question.

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
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python25\lib\ctypes\__init__.py", line 6, in <module>
    import os as _os, sys as _sys
  File "C:\Python25\lib\os.py", line 690, in <module>
    import copy_reg as _copy_reg
  File "C:\Python25\lib\copy_reg.py", line 7, in <module>
    from types import ClassType as _ClassType
  File "C:\Python25\lib\types.py", line 93, in <module>
    import _types
SystemError: _PyImport_FixupExtension: module _types not loaded
[6569 refs]

For reference here is my code:
// pytest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "python.h"

int _tmain(int argc, _TCHAR* argv[])
{
	Py_Initialize();
	PyRun_SimpleString("import ctypes");
	Py_Finalize();
	return 0;
}

Steve




More information about the Python-list mailing list