Pyd cannot be imported, using shiboken6 to bind
-
I'm trying to build widgetbinding from pyside's examples (At D:\Python\Python39\Lib\site-packages\PySide6\examples\widgetbinding) . I successfully built the module pyd but I cannot import the module after building the pyd. I got ImportError when import wiggly in python.
how I built the pyd:
cmake -B ./build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release cd build nmake nmake install cd .. # back to the directory my pyd installed ipython # start testing the importing In [1]: import wiggly --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-8a2812855881> in <module> ----> 1 import wiggly ImportError: DLL load failed while importing wiggly: 找不到指定的模块。
(ImportError: DLL load failed while importing wiggly: The specified module could not be found.)
I think I've already have the dlls needed:
widgetbinding ├── bindings.h ├── bindings.xml ├── build ├── CMakeLists.txt ├── dialog.py ├── libwiggly.dll ├── macros.h ├── main.py ├── README.md ├── shiboken6.abi3.dll ├── wiggly.pyd ├── wigglywidget.cpp ├── wigglywidget.h ├── wigglywidget.py └── __pycache__
another example: samplebinding (also from pyside6's examples) can be successfully built and be imported
I also tried my own C++ Qt library and got the same import error.
My development environment
Python3.9.2 (MSC v.1928 64 bit)
Qt 6.0.2
PySide 6.0.2 (I tried on PySide and Shiboken 6.0.1 version too)
Shiboken6.0.2
Using built in nmake tool from vs 2019Is it a bug? If not, what should I do to be able to use shiboken binded C++ Qt libraries in python?
-
Hi @SGaist, I took you advice and finally found out where the problem is.
I looked into Wependency Walker and realized that I canimport PySide6.QWidgets
before I import wiggly, So that the dlls needed is already loaded for wiggly.
I've been testing wiggly using one singleimport wiggly
in IPython, not runing themain.py
directly in the examples, trying to copy dlls from one place to another, and kept gettingImportError
s.
Now I write:import PySide6.QtWidget import wiggly
and it works.
Thanks for your help!
-
Hi and welcome to devnet,
I can't answer that question directly but things that comes to mind:
- where is the dll installed ?
- if you use a tool like Dependency Walker, does the dll find its dependencies ?
-
Hi @SGaist, I took you advice and finally found out where the problem is.
I looked into Wependency Walker and realized that I canimport PySide6.QWidgets
before I import wiggly, So that the dlls needed is already loaded for wiggly.
I've been testing wiggly using one singleimport wiggly
in IPython, not runing themain.py
directly in the examples, trying to copy dlls from one place to another, and kept gettingImportError
s.
Now I write:import PySide6.QtWidget import wiggly
and it works.
Thanks for your help!