0

I have built a GUI using PyQt5 and wanted to distribute it to other computers without Python installed by packageing it with pynsist. Unfortunately, the default Python, which does exist in the 'Python'-folder of the installation (and which is executable), cannot be found.

I first thought that there must be a problem with the paths pynsist was generating for the shortcut, but it is targeting the right path to pythonw.exe (I am using Python without a terminal) and the .launch.pyw file, which correctly triggers the main() function of the script. E.g. C:\install_GUI\Python\pythonw.exe 'C:\install_GUI\GUI.launch.pyw'

When trying to start the script directly (not using the shortcut) I get the warning message 'Can't find a default Python'.

Any suggestions what causes this problem and how to make it work?

Could this issue be related to the coding of the scripts? This means I have included # -*- coding: utf-8 -*- on top of each script, but the automatically generated .launch.pyw file comes without this line. I know that Python above version 3 has utf-8 coding as a default, but without adding this line to the .launch.pyw file the GUI does not even work on my computer after installation (using Python 3.6.5).

Thank you in advance for your answers!

alex_555
  • 1,092
  • 1
  • 14
  • 27
  • How is this NSIS related? – Anders Feb 20 '18 at 14:51
  • I thought it is relevant since `pynsist` uses NSIS to create the installer and to define the paths (which might cause the problem). – alex_555 Feb 21 '18 at 08:32
  • I suspect that the "can't find a default Python" message mean that the `py` and `pyw` launchers are installed on the machine and associated with the `.py` and `.pyw` file types. The launchers are designed to run files using a Unix style `#!` line at the start of the file. If that's not there, they're probably looking for a default Python installation in the registry. The bundled copy of Python with your app is not registered in the registry. In that situation, I think you probably have to either use the shortcut, or launch it from the command prompt using an explicit path to `pythonw.exe`. – Thomas K Feb 22 '18 at 20:37
  • The launchers were previously installed, but are now uninstalled on this test-computer. Thanks for the tip, I deleted the associations in the registry for the `.py` and `.pyw` files. Unfortunately, when launching the shortcut Python keeps crashing. The `.launch.pyw` files of my build contain the `#!` line and should actually work, but still can't be run; neither by using the shortcut or the console. In respect of the end-users I need to make it work just by using the shortcut. – alex_555 Feb 23 '18 at 08:51

0 Answers0