I want to create a portable PyQt5.2.1 package [Question]



  • hi guys
    I have a problem in using PyQt5
    i have python 2.7 and i had to built PyQt5.2.1 for it, from source.
    ok,
    now it works fine on my system because i have Qt5.2.1, Python 2.7, and PyQt5.2.1 that built with Python 2.7.
    but where is problem?
    i created a GUI with pyqt and QML and i want to give it to a client.but i want just tell him that it install python on his system(or myself install it for him with installer).and here i need a portable QT5.2.1
    but i don't know what stuffs i should put beside PyQt5 package that just put PyQt5 in site-package and my GUI is run on his system.
    i use windows 8 x64.

    thanks in advanced.

    i set QT_QPA_PLATFORM_PLUGIN_PATH
    but i don't know what env varuable should be set
    and my files (exe and dlls) in my PyQt5 package is the same as PyQt5.msi installed package

    this is error:
    “class QWindowsEGLStaticContext *__cdecl QWindowsEGLStaticContext::create(void): Could not initialize egl display: error 12289

    QTQuick: failed to create OpenGL context”


  • Moderators

    Hi,

    I'm not familiar with PyQt, so I don't know what stuff you need to put in your package.

    Subscribe to the "PyQt mailing list":http://www.riverbankcomputing.com/mailman/listinfo/pyqt and ask there -- I think there will be a lot more people there who know how to solve your problem.



  • Just curious, but why python 2? Why not move it over to python 3?



  • ok JKSH
    i follow the steps of http://qt-project.org/wiki/Deploy_an_Application_on_Windows
    but,instead of myApp.exe i have myApp.py that run with python and use qml file, and did all steps for deployment.
    but it give me first error:
    This application failed to start because it could not find or load the Qt platform plugin "windows".

    i am using this two in my QML file :
    import QtQuick 2.0
    import QtQuick.Controls 1.0


  • Moderators

    What happens if you delete Qt5Core.dll from your deployment folder?

    Can you post a screenshot of what's in your deployment folder? (Upload it to a image host, like Google Drive or Microsoft OneDrive or Imgur, and then post a link here)



  • thanks, yes,
    this is my Qt5.2.1 folder: C:\Qt\Qt5.2.1\5.2.1\msvc2012_64
    and this is my PyQt5.2.1: C:\Python27\Lib\site-packages\PyQt5

    my program have this folders and files:
    "js" and "utils" folder
    test.qml and mainLauncher.py files

    i put:
    all .dll files from C:\Qt\Qt5.2.1\5.2.1\msvc2012_64\bin
    all plugins folders from C:\Qt\Qt5.2.1\5.2.1\msvc2012_64\plugins
    all qml folders from C:\Qt\Qt5.2.1\5.2.1\msvc2012_64\qml
    beside my launcher.py
    (there is no need to put all contents of C:\Qt\Qt5.2.1\5.2.1\msvc2012_64\imports beside it?)

    error before deleting Qt5Core.dll:
    This application failed to start because it could not find or load the Qt platform plugin "windows".
    Reinstalling the application may fix this problem.

    error after deleting Qt5Core.dll:
    Traceback (most recent call last):
    File "C:\Users\Madoodia\Desktop\Deployment\mainLauncher.py", line 9, in <module>
    from PyQt5.QtCore import pyqtProperty, QObject, QUrl, pyqtSlot, pyqtSignal
    ImportError: DLL load failed: The specified module could not be found.

    this is image of deployment:
    https://dl.dropboxusercontent.com/u/70052012/Deployment_Folder.jpg

    thanks


  • Moderators

    Thank you for your detailed descriptions and your screenshot. From what you posted, I can confirm that you have followed the guide 100% correctly.

    I think your problem is because your program is not getting plugin paths correctly.

    The poster at "this thread":https://qt-project.org/forums/viewthread/41594/#173330 had a very similar problem -- he followed the guide correctly, but still got the same error message as you. The problem was caused because his program tried to find plugins before QCoreApplication was created. Maybe it's the same for you?

    I don't know how PyQt works, so I don't know if I can help you find a solution. If you still can't work it out, please ask at the PyQt mailing list.

    One last thing I found, which might be helpful: http://pyqt.sourceforge.net/Docs/pyqtdeploy/pyqtdeploy_module.html

    [quote](there is no need to put all contents of C:\Qt\Qt5.2.1\5.2.1\msvc2012_64\imports beside it?)[/quote]No. imports is for Qt Quick 1. That is deprecated now; everyone is encouraged to use Qt Quick 2.



  • thanks you.
    i try and will inform you



  • very good thread, thanks
    i have some progress, but yet it does not work and give some error:
    first error, (This application failed to start because it could not find or load the Qt platform plugin “windows”.
    Reinstalling the application may fix this problem.), is fixed with this way:
    in code of launcher i got the path of this file (here Deployment folder) as dynamically and send it to QApplication.addLibraryPath(path)

    but a new error occured: (i had it before, if you remember i looked for QML_IMPORT_PATH env for that but i reach to this point)
    QQmlApplicationEngine failed to load component
    file:///C:/Users/Madoodia/Desktop/Deployment/test.qml:2 module "QtQuick.Controls" is not installed
    file:///C:/Users/Madoodia/Desktop/Deployment/test.qml:1 module "QtQuick" is not installed
    because i have this two line in test.qml file:
    import QtQuick 2.0
    import QtQuick.Controls 1.0

    what is this error?
    i put all folders of C:\Qt\Qt5.2.1\5.2.1\msvc2012_64\qml beside my app
    why give error?

    i should tell that when i run test.qml it runs, and window is appeared.
    (also, i have QtHidden yet)

    thanks for reply in advanced


  • Moderators

    Have you talked to people at the PyQt mailing list?

    I am only guessing here: Maybe it's because you are not launching an .exe file. You are loading a Python script file, so maybe Qt is searching in the folder where python.exe is.



  • Yes, you are right, and i have post on riverbank's mailing list for pyqt, but anybody does not answer me.

    thanks for your guessing
    i put QtQuick and QtQuick.2 folder and platform folder beside python.exe and proram works.

    but i want to know that how can i tell program that this files is beside you.and first search your folder then if it is not here go to Python27 folder.???

    if help me about paths i really own to you


  • Moderators

    At the beginning of mainLauncher.py, what does os.getcwd() return? What happens if you call os.chdir() to go to the deployment folder, before you start calling Qt stuff?



  • os.getcwd() >>> C:\Users\Madoodia\Desktop\Deployment

    you mean this :
    path = os.getcwd()
    os.chdir(path)
    ?

    nothing
    i'm in deployment folder


  • Moderators

    [quote author="madoodia" date="1398588817"]os.getcwd() >>> C:\Users\Madoodia\Desktop\Deployment

    you mean this :
    path = os.getcwd()
    os.chdir(path)
    ?

    nothing
    i'm in deployment folder[/quote]Yes, that's what I meant. It didn't work though...

    Ok, try playing around with QQmlEngine::addImportPath() or QQmlEngine::addPluginPath() (see http://qt-project.org/doc/qt-5/qqmlengine.html) -- these are like QApplication::addLibraryPath().

    If you used a QQuickView, you can get the engine by calling QQuickView::engine()



  • hey there
    yes
    i work with this and i got the good results.
    and i find the way.not Portable PyQt5 but i can find more thing that i will document all off that in these days.
    but a new problem occurs.
    my program works fine in my labtop.
    i switch to pyinstaller to make it executable and i had infinite problems.
    i solved all off them too.
    but there is a big problem that i could not solve it yet.
    i changed program to one exe file and it works in my labtop fine.
    but when i transform it to another clean pc or clean VM it does not work and give this error (again):
    This application failed to start because it could not find or load the Qt platform plugin “windows”.
    Reinstalling the application may fix this problem.
    :)
    this error want to kill me...
    any feedback welcome.
    thanks again


  • Moderators

    Load your .exe with Dependency Walker (http://www.dependencywalker.com/ ) and choose Profile -> Start Profiling.

    That will show you where it's searching for DLLs.

    [quote]i switch to pyinstaller to make it executable[/quote]The search paths for the .exe file might be different from the .py file



  • ok
    i did that an find that all Loading is between two same commands,for example one line of LoadLibraryW ... some other lines...again LoadLibraryW

    and this is result:
    LoadLibraryW("C:\Users\vm1\AppData\Local\Temp_MEI26242\qt5_plugins\platforms\qwindows.dll") called from "QT5CORE.DLL" at address 0x00000000600C85EF.
    Loaded "QWINDOWS.DLL" at address 0x000007FE3F840000. Successfully hooked module.
    Loaded "WINMM.DLL" at address 0x000007FE44B80000. Successfully hooked module.
    Loaded "OLEAUT32.DLL" at address 0x000007FE4D6A0000. Successfully hooked module.
    Unloaded "QWINDOWS.DLL" at address 0x000007FE3F840000.
    Unloaded "OLEAUT32.DLL" at address 0x000007FE4D6A0000.
    Unloaded "WINMM.DLL" at address 0x000007FE44B80000.
    LoadLibraryW("C:\Users\vm1\AppData\Local\Temp_MEI26242\qt5_plugins\platforms\qwindows.dll") returned NULL. Error: The specified module could not be found (126).
    what do you find from this?
    the bold snippet in dependecy graph has red color.
    look likes load successfully but...



  • and this is in my labtop that run exe file completely:

    LoadLibraryW("C:\Users\Madoodia\AppData\Local\Temp_MEI245962\qt5_plugins\platforms\qwindows.dll") called from "QT5CORE.DLL" at address 0x000000006A5885EF.
    Loaded "QWINDOWS.DLL" at address 0x000007FCC8CF0000. Successfully hooked module.
    Loaded "WINMM.DLL" at address 0x000007FCE7060000. Successfully hooked module.
    Loaded "OLEAUT32.DLL" at address 0x000007FCEB700000. Successfully hooked module.
    Loaded "LIBEGL.DLL" at address 0x000007FCE2E30000. Successfully hooked module.
    Loaded "WINMMBASE.DLL" at address 0x000007FCE5DB0000. Successfully hooked module.
    DllMain(0x000007FCE5DB0000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "WINMMBASE.DLL" called.
    DllMain(0x000007FCE5DB0000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "WINMMBASE.DLL" returned 1 (0x1).
    DllMain(0x000007FCE7060000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "WINMM.DLL" called.
    DllMain(0x000007FCE7060000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "WINMM.DLL" returned 1 (0x1).
    DllMain(0x000007FCEB700000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "OLEAUT32.DLL" called.
    DllMain(0x000007FCEB700000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "OLEAUT32.DLL" returned 1 (0x1).
    DllMain(0x000007FCE2E30000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "LIBEGL.DLL" called.
    DllMain(0x000007FCE2E30000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "LIBEGL.DLL" returned 1 (0x1).
    DllMain(0x000007FCC8CF0000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "QWINDOWS.DLL" called.
    DllMain(0x000007FCC8CF0000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "QWINDOWS.DLL" returned 1 (0x1).
    LoadLibraryW("C:\Users\Madoodia\AppData\Local\Temp_MEI245962\qt5_plugins\platforms\qwindows.dll") returned 0x000007FCC8CF0000.

    comprise inbetween codes



  • There is 5 DLL that should be loaded:
    QWINDOWS.DLL
    WINMM.DLL
    OLEAUT32.DLL
    LIBEGL.DLL
    WINMMBASE.DLL

    i don't know how should i read the address of them:
    Loaded “QWINDOWS.DLL” at address 0×000007FCC8CF0000 ...

    you know?



  • i find this 3 files in windows/system32
    WINMM.DLL
    OLEAUT32.DLL
    WINMMBASE.DLL
    that i think should be shipped with exe file.

    and this to is shipped with file
    QWINDOWS.DLL
    LIBEGL.DLL

    and i think it can't use it because it don't have permission to access to them.
    :(


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.