Title pyqt5 based app not portable to other machine in standalone mode
Priority bug Status resolved
Superseder Nosy List rboulanger
Assigned To Keywords standalone, wrong_execution

Created on 2015-12-07.16:29:15 by rboulanger, last changed by kayhayen.

File name Uploaded Type Edit Remove
Bildschirmfoto 2015-12-08 um 13.22.55.png rboulanger, 2015-12-08.12:38:45 image/png
msg2506 (view) Author: kayhayen Date: 2018-08-23.23:25:44
All these issues should be fixed now.

msg1736 (view) Author: rboulanger Date: 2015-12-08.13:07:21
Continue trying on the linux front.
I tried to start the compiled app now under manjaro linux 
rtWriter: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof 
(_nl_value_type_LC_COLLATE) / sizeof (_nl_value_type_LC_COLLATE[0]))' failed.
Abgebrochen (Speicherabzug geschrieben)
(whatever this means, but maybe it helps to narrow the search)
msg1735 (view) Author: rboulanger Date: 2015-12-08.12:38:45
Further investigations on the windows10 front:
when running on the machine where the application was compiled i figured out that the 
app is using _ctypes.pyd, _hashlib.pyd as well as python3.dll from the local python 
installation. after copying those files into the distribution package, the app now is 
transportable between different windows machines ;)
msg1734 (view) Author: rboulanger Date: 2015-12-08.11:44:45
Concerning the error on OSX:
On OSX I opened the executable with an code editor and found inside:
/usr/lib/libc++.1.dylibX/Library/Frameworks/Python.framework/Versions/3.4/Python

so it seems the pythonpath is somekind hardcoded within the executable, was makes 
clear, that this app cannot run on a different machine with no python installed
msg1733 (view) Author: rboulanger Date: 2015-12-08.10:19:06
after trying around with different platforms I come to the following result:

compiled under ubuntu 12.04 running under ubuntu 15.10
compiler: gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
./rtWriter: : ELF: ���o: Error 1746332867

compiled under ubuntu 15.10 running ubuntu 12.04
compiler: gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
./rtWriter: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument

compiled under windows10, running on other machine
compiler: lates Visualstudio Compiler, whatever this is)
(Nothing happens, no start, no error, nothing at all)

compiled under Mac OSX 'El Capitan' running under Mac OSX 'Yosemite' (different Machine)
compiler: Apple LLVM version 7.0.0 (clang-700.1.76)

dyld: Library not loaded: /Library/Frameworks/Python.framework/Versions/3.4/Python
  Referenced from: /Volumes/Macintosh HD/Development/python3/rtWriterMac.dist/./rtWriter
  Reason: image not found
Trace/BPT trap: 5

So in short, wherever I can compile the Application with nuitka I can execute it and it is amazing fast.
But all in all, the executable binaries are not portable to any other machine. 
I don't think this has something to do with the compiler, but may with the linker concerning the Qt5 libs ?
msg1732 (view) Author: rboulanger Date: 2015-12-07.16:29:15
Again me, with another issue sorry ;)
this time linux

I have an option for running the included server of my application in headless mode on linux servers without X installed.
To do so the app has to be started with xvfb (dummy X Server) as mentioned in many forums and discussions

starting the app via python like:

xvfb-run --server-args="-screen 0 1360x768x24" python3 -s  works fine

starting the nuitka compiled app 
xvfb-run --server-args="-screen 0 1360x768x24" ./rtWriter.exe -s

results in 

This application failed to start because it could not find or load the Qt platform plugin "xcb".
Available platform plugins are: 
linuxfb (from /home/robert/development/WriterBin/PyQt5/qt-plugins/platforms), 
minimal (from /home/robert/development/WriterBin/PyQt5/qt-plugins/platforms), 
offscreen (from /home/robert/development/WriterBin/PyQt5/qt-plugins/platforms), 
xcb (from /home/robert/development/WriterBin/PyQt5/qt-plugins/platforms)

Reinstalling the application may fix this problem.

so I first checked the library paths via 

for path in QApplication.libraryPaths():                                 

which shows :    
1 /home/robert/development/WriterBin/PyQt5/qt-plugins

so the application knows where the plugins are located, (and they are really there, so nuitka copied them right over)
as we already can see in the error message above

Finally i tried to add the library path from the Qt installation of the machine like here:

for path in QApplication.libraryPaths():                                 
if getattr(sys, 'frozen', True):                                                                                                 
    Qtplugin_path = '/home/robert/Qt/5.5/gcc_64/plugins/' 
app = QApplication(sys.argv)                                            
for path in QApplication.libraryPaths():                                 

output now is :

xvfb-run --server-args="-screen 0 1360x768x24"  ./rtWriter -s 
1 /home/robert/development/WriterBin/PyQt5/qt-plugins
2 /home/robert/Qt/5.5/gcc_64/plugins
2 /home/robert/development/WriterBin/PyQt5/qt-plugins
2 /home/robert/development/WriterBin
Connected: Roberts Server :
Server is listening ?  True

as we can see the line "1 /home/robert/development/WriterBin/PyQt5/qt-plugins" is printed BEFORE I added the QT installation 
path while
all lines starting with 2 are printed after I set manually the path to the Qt Installation
And the app is starting now.

I googled around and found this article:  concerning Qt plugins and frozen python apps. Here 
also this mysteric rpath thing shows up we discussed in issue 272 

have a look in the linux section of the article you will find:

A) When building the the app: Qt (actually the linker) normally sets the RPATH just pointing to the .so files where Qt’s 
installer put them (for example in my case /home/henry/Qt/5.4/gcc_64/lib) which of course is fine and dandy for your 
development machine but less so for the other Linux PC.
However we can tweak that setting by adding a line to our project’s .pro file (I usually put it at the end of my .pro file):

QMAKE_LFLAGS += -Wl,-rpath,"'\$$ORIGIN'"
What we want is to insert the magic word $ORIGIN as the first RPATH setting, this will cause Linux to look for .so files to 
load in the same directory as the .exe/ELF file. (The extra decoration "'\$...'" is needed for surviving the heavy munging 
during the build process before arriving at the linker.)
Actually we can equally well use “.” as an RPATH (i.e. QMAKE_LFLAGS += -Wl,-rpath,"." this will perform the same feat as 
$ORIGIN) but the docs advise us to use $ORIGIN, so $ORIGIN it is.
(Note: there are a couple of other .pro file flag commands available for this, for example: QMAKE_RPATHDIR += ":'\$$ORIGIN'" 
but I prefer QMAKE_LFLAGS += ... because it causes $ORIGIN to appear as the first RPATH.)

maybe this helps
Date User Action Args
2018-08-23 23:25:44kayhayensetstatus: chatting -> resolved
messages: + msg2506
2015-12-08 13:07:21rboulangersetmessages: + msg1736
2015-12-08 12:38:45rboulangersetfiles: + Bildschirmfoto 2015-12-08 um 13.22.55.png
messages: + msg1735
2015-12-08 11:44:45rboulangersetmessages: + msg1734
2015-12-08 10:19:07rboulangersetstatus: unread -> chatting
messages: + msg1733
title: qt-plugins not loaded in compiled app -> pyqt5 based app not portable to other machine in standalone mode
2015-12-07 16:29:15rboulangercreate