1

I have built a GUI using PyQt5 and wanted to distribute it to other computers without Python installed by packageing it with pynsist. Unfortunately, when launching the shortcuts produced by the installer, the GUI does not open as expected and Python keeps crashing (even if Python is instlalled).

The console shows the following error upon crashing:

ModuleNotFoundError: No module named 'sip'.

This is due to from PyQt5.QtCore import *.

Unfortunately, when launching the .launch.py script on a computer with Python installed, everything works fine. I suppose this is because it then targets the installed version instead of the version included in the build of the GUI. However, the shortcuts do not work, no matter if Python is installed, giving me the above error.

Any ideas how to fix this problem and make the shortcuts work on computers that do not have Python installed?

Thank you in advance!

alex_555
  • 1,092
  • 1
  • 14
  • 27

2 Answers2

3

When I first encountered this problem I simply added sip.pyd to my project-folder. You can find it under:

x:/path-to-python/Lib/site-packages/sip.pyd

but what realy solved my problem was using pyinstaller. It automatically detects most dependencies and most of the time runs without complicated configurations.

pip install pyinstaller
pyinstaller main.py 
# done
Skandix
  • 1,916
  • 6
  • 27
  • 36
  • Pyinstaller would be nice. However, I'm more or less bound to `pynsist`, since my end-users won't have `Python` installed. Thus, I need to incorporate a functioning `Python` instance. I tried to copy the `sip.pyd` file into the project folder in different places, but it still tells me that `sip` is missing. Can you please specify where I should paste it? – alex_555 Mar 12 '18 at 14:39
  • @alex_555: Pyinstaller will provide a full python-instance, with all required modules (or most). No Python-installation is needed on the running maschine. Regarding the sip-module: you can place it whereever you like, simply add the path to it (**before first depending import!**) with `sys.path.append( os.path.realpath( 'relative/path' ) )` – Skandix Mar 12 '18 at 15:04
  • I tried to Pyinstaller and it works so much better! Although there are a few things left, this question is answered! Thank you! – alex_555 Mar 13 '18 at 09:17
  • What to do on a mac? – USERNAME GOES HERE Jun 29 '20 at 16:13
2

Sip is a separate package which PyQt5 requires. You can include it with your application by listing it in pypi_wheels=, as in the PyQt5 example:

[Include]
packages=listapp
pypi_wheels= PyQt5==5.6
    sip==4.18

If you're using the latest version of PyQt5 (5.10.1), then the latest version of sip (4.19.8) should work with it.

Thomas K
  • 39,200
  • 7
  • 84
  • 86
  • Thanks, I'll probably try that and see if it works later, but for now I'm well served with Pyinstaller. Just as a side note: as great as Pyinstaller is, the only thing I really miss is the opportunity to automatically create shortcuts compared to pynsist without having to build a workaround for that. – alex_555 Mar 14 '18 at 11:03
  • Ironically, Pyinstaller does not actually make installers (at least not normally; maybe it has some mode for that). Pynsist does, which is why it gives you shortcuts. – Thomas K Mar 15 '18 at 11:59
  • This is actually the reason why I preferred pynsist in the first place, since most end-users are accustomed to using an installer and working with the shortcuts. However, Pyinstaller created fewer problems and worked quite well so that I distributed the beta version of my GUI with it. But I'll probably come back later for trying to make pynsist also work. – alex_555 Mar 19 '18 at 12:26