0

I have a small pyqt5 project written in python. I generate .cpp file using cython --embed , compiled with MSVC and it is working in my machine with no problem but I want to distribute .exe with no python installed target machines. Pretty much confused about pyqt import as I get error initialization of QtCore failed without raising an exception. I tried various stuff, I put my effort a whole day but briefly put necessary files to .exe location and removed python36._pth , which is as follows

.\python36.dll
.\python36.zip (from python-3.6.5-embed-amd64.zip)
.\PyQt5  (copied from Anaconda3\Lib\site-packages)
.\platforms  (required plugins for windows)

I guess it requires also sip but I could not figure out elegant way to add pyqt5 as there is no documentation about distribution of embedded python with imported modules (site-packages). Any help would be extremely great.

scorp
  • 25
  • 1
  • 6
  • This isn't quite the same as https://stackoverflow.com/questions/52959902/make-executable-file-from-multiple-pyx-files-using-cython and the linked questions since you're prepared to copy files alongside it. The upshot is that it really isn't designed for this and you should use py2exe or something similar. – DavidW Sep 19 '20 at 07:40
  • Also this https://stackoverflow.com/a/56861396/5769463 describes how python searches for side packages at the start up. You must put your side packages into the right place or set python path in your embedded interpreter explicitly – ead Sep 19 '20 at 07:46
  • @DavidW I know but I want to build .dll from cpp. And also pyinstaller build big sizes :( – scorp Sep 19 '20 at 08:58
  • And the big sizes are simply because everything it bundles is necessary. If you succeed in getting Cython to work then it'll be just as big – DavidW Sep 19 '20 at 09:03
  • @ead I tried various options also with _pth but the problem is not about path. It imports the pyqt5 but raise ```systemerror``` . Do I need to put compiled pyc of pyqt ? – scorp Sep 19 '20 at 09:16
  • Do you have also all needed dlls in pyqt5 folder? – ead Sep 19 '20 at 09:50
  • Yes, added to PyQt5\Qt but not worked. I also tried with different paths but same error – scorp Sep 19 '20 at 12:14
  • Any help would be great – scorp Sep 28 '20 at 09:39
  • Does this answer your question? [Minimal set of files required to distribute an embed-Cython-compiled code and make it work on any machine](https://stackoverflow.com/questions/62390978/minimal-set-of-files-required-to-distribute-an-embed-cython-compiled-code-and-ma) – Basj May 06 '22 at 19:38

1 Answers1

1

I solved adding .\sip.pyd. Then I checked resulting folder size , it was around 20 MB. With Pyinstaller, resulting .exe is about 43 MB

scorp
  • 25
  • 1
  • 6