Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Add Shiboken2 to QtCreator



  • Hi,

    I started to learn how to bind Pyside2 and Qt (C++).
    I have installed PySide2 using pip install pip install PySide2==5.14.2
    5.14.2 is the version that I work with in Qt C++ (in QtCreator).

    Now I have:

    • C:\Anaconda3\envs\MyEnv38\Lib\site-packages\PySide2
    • C:\Anaconda3\envs\MyEnv38\Lib\site-packages\shiboken2
    • C:\Qt where I have: MaintenanceTool.exe, folder where 5.14.2, Tools folder etc.

    As you can see I use python env MyEnv38 and I do not set PATH var to there.

    Now I want:

    1. check wether PySide2 installed with pip install is built with MSVC 2017 x64 (this architecture I'm working with and all my libraries are built with it)
    2. somehow add shiboken2 to my Qt Creator kits (or something) so I could launch examples from pyside-setup\examples and write codes. Now when I try to open pyside-setup\examples\scriptableapplication.pro I get:
      Project MESSAGE: Using python interpreter: python
      Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640
      Project ERROR: Unable to locate the shiboken2-generator package location

    Here is how I set Python in QtCreator:
    839695c7-0fa0-41f5-9542-1b38d6bbd957-image.png



  • I solved this issue: the problem was that directories to my python:

    • C:\Anaconda3\envs\MyEnv38
    • C:\Anaconda3\envs\MyEnv38\Scripts
    • C:\Anaconda3\envs\MyEnv38\Library\bin

    were somewhere at the end of the PATH var. So Windows apps (probably AppData\Local\Microsoft\WindowsApps) used to throw its warnings and errors before the compiler gets Python var.
    Thus I moved Python vars to the very top.

    Then I can run QMake of pyside-setup\examples\scriptableapplication.pro wich is in the F:\Qt\Downloaded\pyside-setup\examples\scriptableapplication
    But when I run it I get the error:
    764cfb6c-8ca0-4d15-9426-ae76558bc918-image.png

    Here I found some solution but it doesn't work.
    My QT_PLUGIN_PATH includes only C:\apps\MSVC_apps_release\CTK\bin CTK widgets and if I delete this variable then the problem is not solved.

    Then if I set new variable QT_QPA_PLATFORM_PLUGIN_PATH with value C:\Anaconda3\envs\MyEnv38\Lib\site-packages\PySide2\plugins\platforms then after running the application I get the output:
    f161bbdb-ca64-431c-9b83-4959e1a2e3df-image.png

    I don't know what the output should be without errors but here I can see Fatal Python error wich means that something is not going well...

    Please help me understand how to work with Python in Qt

    By the way there is no problem to use PySide2 in PyCharm but I need to somehow learn how to perform Python C++ bindings


Log in to reply