Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Pyd cannot be imported, using shiboken6 to bind

    Language Bindings
    shiboken qt6 binding pyside6 c++
    2
    4
    1318
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Cr0ss
      Cr0ss last edited by Cr0ss

      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
      cf93b6b1-619c-4309-abd2-8a7573ccdc2f-image.png

      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 2019

      Is it a bug? If not, what should I do to be able to use shiboken binded C++ Qt libraries in python?

      1 Reply Last reply Reply Quote 0
      • Cr0ss
        Cr0ss @SGaist last edited by

        Hi @SGaist, I took you advice and finally found out where the problem is.
        I looked into Wependency Walker and realized that I can import PySide6.QWidgets before I import wiggly, So that the dlls needed is already loaded for wiggly.
        I've been testing wiggly using one single import wiggly in IPython, not runing the main.py directly in the examples, trying to copy dlls from one place to another, and kept getting ImportErrors.
        Now I write:

        import PySide6.QtWidget
        import wiggly
        

        and it works.

        Thanks for your help!

        1 Reply Last reply Reply Quote 1
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          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 ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          Cr0ss 1 Reply Last reply Reply Quote 0
          • Cr0ss
            Cr0ss last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • Cr0ss
              Cr0ss @SGaist last edited by

              Hi @SGaist, I took you advice and finally found out where the problem is.
              I looked into Wependency Walker and realized that I can import PySide6.QWidgets before I import wiggly, So that the dlls needed is already loaded for wiggly.
              I've been testing wiggly using one single import wiggly in IPython, not runing the main.py directly in the examples, trying to copy dlls from one place to another, and kept getting ImportErrors.
              Now I write:

              import PySide6.QtWidget
              import wiggly
              

              and it works.

              Thanks for your help!

              1 Reply Last reply Reply Quote 1
              • First post
                Last post