Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102150 > unrolled thread

Windows - Embedded Python in C++: ImportError: DLL load failed. Python expert advice needed.

Started byftpronk@engits.com
First post2016-01-27 03:47 -0800
Last post2016-01-27 03:47 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Windows - Embedded Python in C++: ImportError: DLL load failed.  Python expert advice needed. ftpronk@engits.com - 2016-01-27 03:47 -0800

#102150 — Windows - Embedded Python in C++: ImportError: DLL load failed. Python expert advice needed.

Fromftpronk@engits.com
Date2016-01-27 03:47 -0800
SubjectWindows - Embedded Python in C++: ImportError: DLL load failed. Python expert advice needed.
Message-ID<9cfad75c-0818-4160-acdc-c9bcbe055c43@googlegroups.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!

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web