Important: Please read the 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\ I get:
      Project MESSAGE: Using python interpreter: python
      Python was not found but can be installed from the Microsoft Store:
      Project ERROR: Unable to locate the shiboken2-generator package location

    Here is how I set Python in QtCreator:

  • 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\ wich is in the F:\Qt\Downloaded\pyside-setup\examples\scriptableapplication
    But when I run it I get the error:

    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:

    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