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

qt python development - pyside2



  • Trying to run Qt in Python using PySide2.
    But I am getting the following error:

    qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found.
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    
    Available platform plugins are: minimal, offscreen, windows.
    

    My configuration is Windows 10 with Anaconda and python 3.6 (all latest versions).
    I have Qt installed and working (c:\qt) but it is not in the path environment variable so it shouldn't be causing problems.
    I noticed that qt library files (.dll) are present both in:

    1. C:\Users\user\Anaconda3\Lib\site-packages\PySide2
    2. C:\Users\user\Anaconda3\Library\bin
      I am running from within the Anaconda Prompt and the path environment variable starts with:
    • C:\Users\user\Anaconda3
    • C:\Users\user\Anaconda3\Library\mingw-w64\bin
    • C:\Users\user\Anaconda3\Library\usr\bin
    • C:\Users\user\Anaconda3\Library\bin
    • C:\Users\user\Anaconda3\Scripts
    • C:\Users\user\Anaconda3\bin

    I've searched various forums with similar problems, all pointing to path problems, but I haven't been able to find a solution


  • Lifetime Qt Champion

    Hi,

    Since you are using conda, why are you trying to use your own installation of Qt ?
    You should rather use the dependencies that came with conda.



  • I am using conda's files.
    I just mentioned that the additional qt installation (used for c++ development) does not "clash" as its path is not present in the path environment variable.

    from the various posts online it seems that conda and qt don't "get along" too well.
    btw, I'm experiencing the same difficulties on another computer (again win-10 and conda)


  • Lifetime Qt Champion

    Just in case, did you check that all your packages are coming from the same conda channel ?



  • Try to first set QT_DEBUG_PLUGINS=1 to get more info on what is failing: https://stackoverflow.com/a/51563781/2741329



  • Thanks for the feedback.
    After setting the QT_DEBUG_PLUGINS environment flag, I get the following:

    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/user/Anaconda3/Library/plugins/platforms" ...
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/user/Anaconda3/Library/plugins/platforms/qminimal.dll"
    Found metadata in lib C:/Users/user/Anaconda3/Library/plugins/platforms/qminimal.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "minimal"
            ]
        },
        "className": "QMinimalIntegrationPlugin",
        "debug": false,
        "version": 329218
    }
    
    
    Got keys from plugin meta data ("minimal")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/user/Anaconda3/Library/plugins/platforms/qoffscreen.dll"
    Found metadata in lib C:/Users/user/Anaconda3/Library/plugins/platforms/qoffscreen.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "offscreen"
            ]
        },
        "className": "QOffscreenIntegrationPlugin",
        "debug": false,
        "version": 329218
    }
    
    
    Got keys from plugin meta data ("offscreen")
    QFactoryLoader::QFactoryLoader() looking at "C:/Users/user/Anaconda3/Library/plugins/platforms/qwindows.dll"
    Found metadata in lib C:/Users/user/Anaconda3/Library/plugins/platforms/qwindows.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
        "MetaData": {
            "Keys": [
                "windows"
            ]
        },
        "className": "QWindowsIntegrationPlugin",
        "debug": false,
        "version": 329218
    }
    
    
    Got keys from plugin meta data ("windows")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/user/Anaconda3/platforms" ...
    Cannot load library C:\Users\user\Anaconda3\Library\plugins\platforms\qwindows.dll: The specified procedure could not be found.
    QLibraryPrivate::loadPlugin failed on "C:/Users/user/Anaconda3/Library/plugins/platforms/qwindows.dll" : "Cannot load library C:\\Users\\user\\Anaconda3\\Library\\plugins\\platforms\\qwindows.dll: The specified procedure could not be found."
    qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found.
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    
    Available platform plugins are: minimal, offscreen, windows.
    

    regarding conda channels, the following is a partial output of conda list (with qt related packages, and a few other packages):

    # Name                    Version                   Build  Channel
    pillow                    5.1.0            py36h0738816_0
    pip                       10.0.1                   py36_0
    pkginfo                   1.4.2                    py36_1
    pluggy                    0.6.0                    py36_0
    ply                       3.11                     py36_0
    progress                  1.4                      py36_0
    prometheus_client         0.3.0                    py36_0
    prompt_toolkit            1.0.15           py36h60b8f86_0
    protobuf                  3.5.2            py36h6538335_0
    psutil                    5.4.6            py36hfa6e2cd_0
    py                        1.5.4                    py36_0
    pyasn1                    0.4.3                    py36_0
    pyasn1-modules            0.2.2                    py36_0
    pycodestyle               2.4.0                    py36_0
    pycosat                   0.6.3            py36h413d8a4_0
    pycparser                 2.18                     py36_1
    pycrypto                  2.6.1            py36hfa6e2cd_9
    pycurl                    7.43.0.2         py36h74b6da3_0
    pyflakes                  2.0.0                    py36_0
    pygments                  2.2.0            py36hb010967_0
    pylint                    1.9.2                    py36_0
    pyodbc                    4.0.23           py36h6538335_0
    pyopenssl                 18.0.0                   py36_0
    pyparsing                 2.2.0                    py36_1
    pyqt                      5.6.0            py36hb5ed885_5
    PySide2                   5.11.0                    <pip>
    pysocks                   1.6.8                    py36_0
    pytables                  3.4.4            py36he6f6034_0
    pytest                    3.6.3                    py36_0
    pytest-arraydiff          0.2              py36h39e3cac_0
    pytest-astropy            0.4.0                    py36_0
    pytest-doctestplus        0.1.3                    py36_0
    pytest-openfiles          0.3.0                    py36_0
    pytest-remotedata         0.3.0                    py36_0
    python                    3.6.6                hea74fb7_0
    python-dateutil           2.7.3                    py36_0
    pytorch                   0.3.0                py36_0.3.0    peterjc123
    pytz                      2018.5                   py36_0
    pywin32                   223              py36hfa6e2cd_1
    pywinpty                  0.5.4                    py36_0
    pyyaml                    3.13             py36hfa6e2cd_0
    pyzmq                     17.0.0           py36hfa6e2cd_3
    qt                        5.6.2           vc14h6f8c307_12
    qtawesome                 0.4.4            py36h5aa48f6_0
    qtconsole                 4.3.1            py36h99a29a9_0
    qtpy                      1.4.2                    py36_0
    vc                        14.1                 h0510ff6_3
    vs2015_runtime            15.5.2                        3
    vs2017_runtime            15.5.2                        1
    


  • Update:
    I uninstalled the pip version of PySide2
    and installed the conda-forge version

    now things seem to be working (at least a qt window opened...)

    thanks



  • I just ran into this problem and had the exact same output. From my troubleshooting it seems like qwindows.dll in Anaconda Library (C:/Users/user/Anaconda3/Library/plugins/platforms/qwindows.dll) is not the same as the one in the pyside2 folder, therefore it finds a qwindows.dll but it's not the correct one so it can't load it. I had to uninstall and reinstall Anaconda and then install pyside2 within the environment (creating an anaconda env in pycharm and installing pyside2 also through pycharm, but not using conda). Correct location for my qwindow.dll was C:/ProgramData/Anaconda3/envs/my_project/lib/site-packages/PySide2/plugins/platforms/qwindows.dll"



  • I have the same issue and fixed in this way
    In Anaconda installation folder I went to : (change it to your installed path):

    C:\ProgramData\Anaconda3\Lib\site-packages\PySide2

    Edit this file by adding the following code lines :

    # below the line 23 type.__signature__
        pyside_package_dir =  os.path.abspath(os.path.dirname(__file__))
        dirname = os.path.dirname(__file__)
        plugin_path = os.path.join(dirname, 'plugins', 'platforms')
        os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
    

    save this file and try again and the issue should be gone :)


Log in to reply