0

When I try to embed python wx in C like this:

#include "stdafx.h"
#ifdef _DEBUG
  #undef _DEBUG
  #include <Python.h>
  #define _DEBUG
#else
  #include <Python.h>
#endif

int _tmain(int argc, _TCHAR* argv[])
{
  PyObject* pyModule;
  Py_Initialize();
  //_pyModule = PyImport_ImportModule("__main__");
  //_pyModule = PyImport_ImportModule("csi");
  pyModule = PyImport_ImportModule("wx");
  if(!pyModule)
    PyErr_Print();
  return 0;
}

it fails:

->Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\wx-2.8-msw-ansi\wx\__init__.py", line 45, in <module>
  from wx._core import *
  File "C:\Python27\lib\site-packages\wx-2.8-msw-ansi\wx\_core.py", line 4, in <module>
  import _core_
  ImportError: DLL load failed: The specified module could not be found.

could be a problem with msvc*90.dll files?

I am using VS2005, Python 2.7, wxPython 2.8.12.1 (ansi) for Python 2.7

Further MS VC++ 2008/2010 Redistributables are installed.

thanks for help.

1
  • Why are you doing that? You could just use wxWidgets instead since it's actually C++. Commented Jun 26, 2012 at 13:52

1 Answer 1

3

Finally I found the solution:

it is a Manifest problem. Thanks to Microsof dll-hell...

This helps:

//_core_.pyd ImportError
// _core_.pyd is in fact a dll. it can be renamed.
// The problem is that _core_.pyd depends on some Microsoft.VC90.CRT libraries
//this dependency must be added to make it work
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' language='*'\"")
Sign up to request clarification or add additional context in comments.

1 Comment

This really works, I use a python module that is a extension, when I launch the python interpreter on windows and import that module, there is no error. But when I use this module in a project that uses boost python, boost::python::import (which uses PyImport_ImportModule) will always throw import error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.