简体   繁体   English

C++ Qt库shiboken绑定pyd无法导入

[英]C++ Qt library shiboken bound pyd cannot be imported

I'm trying to build the example widgetbinding from pyside's examples.我正在尝试从widgetbinding的示例构建示例小部件绑定。 I successfully built the module pyd but I cannot import the module after I built the pyd .我成功构建了模块pyd但在构建pyd后无法导入模块。 I also tried my own C++ Qt library and got the same error.我也尝试了我自己的 C++ Qt 库并得到了同样的错误。

I use cmake to build the binding module:我使用 cmake 构建绑定模块:

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: 找不到指定的模块。

trying to include the module in python试图将模块包含在 python 中

I'm on Windows 10 and using Qt 6.0.2, Shiboken6.0.1 and PySide6.0.1.我在 Windows 10 并使用 Qt 6.0.2、Shiboken6.0.1 和 PySide6.0.1。 The python on my machine is download directory from python.org.(Does it matters that I'm not using a python built on vs2019 on my own?)我机器上的 python 是从 python.org 下载的目录。(我没有使用基于 vs2019 构建的 python 是否重要?)

I can successfully build the samplebinding from pyside6/examples, which doesn't contain any Qt related C++ code.我可以从 pyside6/examples 成功构建 samplebinding,它不包含任何与 Qt 相关的 C++ 代码。 Able to import the module in python能够导入python中的模块

I've found the solution.我找到了解决方案。

I got this ImportError because I'm testing the pyd on IPython using one single line:我得到这个 ImportError 是因为我正在使用一行在 IPython 上测试 pyd:

import wiggly

but the pyd in this case(built as a Qt library) have dependencies on dlls like pyside6.abi3.dll , QtWidgets.dll , etc.但在这种情况下,pyd(构建为 Qt 库)依赖于pyside6.abi3.dllQtWidgets.dll等 dll

So when I import PySide6.Qwidgets before importing wiggly, It works: Now I write:因此,当我在导入 wiggly 之前导入 PySide6.Qwidgets 时,它可以工作:现在我写:

import PySide6.QtWidget
import wiggly

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM