Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102150
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2016-01-27 03:47 -0800 |
| Message-ID | <9cfad75c-0818-4160-acdc-c9bcbe055c43@googlegroups.com> (permalink) |
| Subject | Windows - Embedded Python in C++: ImportError: DLL load failed. Python expert advice needed. |
| From | ftpronk@engits.com |
I've been busy porting a Linux code to Windows, and originally decided to go for the mingw-w64 toolchain set, with gcc-4.8 and win32 threading model.
I'm embedding Python in C++ code, and I need to be able to import specific modules, like PySide, to eventually embed an IPython qtconsole in a C++ Qt window. This all works under Linux, so the approach is sound. And everything compiled properly under Windows too. PySide was installed via pip.
Now, from a normal Python/IPython console on the Windows system, I can import what I want:
import PySide.QtCore
No problem here, as expected. But when on the embed side I do:
PyRun_SimpleString("import PySide.QtCore");
I get the following error:
Traceback (most recent call last):
File "<string>", line 2, in <module>
ImportError: DLL load failed: The specified procedure could not be found.
When I import:
PyRun_SimpleString("import PySide");
It works, but I get an empty PySide object. If I import "sys", "os", or "math", all the modules work as expected though, which is probably due to the fact that they are compiled in python27.dll.
So I'm a bit puzzled as to what is happening. Why can I start a Python embedded interpreter, load the builtin modules but not external modules? (I tried other modules like matplotlib / numpy, which didn't work either).
I very strongly suspect the problem to be a linking error, as python27.dll is linked to msvcr90.dll, and mingw-w64 links to msvcrt.dll, meaning my library will be linked to the wrong dll. But in that case, why am I able to load and run Python nonetheless?
Thanks for the help!
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Windows - Embedded Python in C++: ImportError: DLL load failed. Python expert advice needed. ftpronk@engits.com - 2016-01-27 03:47 -0800
csiph-web