2
votes

My program works fine if run from Python.

I am now packaging this into an exe using Pyinstaller.

pyinstaller --onefile path/to/my/file.py

I am able to run the exe and so is anyone else if Python is installed on their system.

If Python is not installed, when the exe is run through terminal this error is seen:

ImportError: No module named 'Pyside'

The program does not use this module. The only libraries it uses are:

os, sys, glob, selenium, PyQt4, warnings

Installing and importing Pyside is not an option (I have tried this) as I am using Python 3.5.

Why is the created exe looking for the PySide module on a system without Python but not on a system with Python installed? Thanks

EDIT 1

It appears the issue is with PyQt4 as the below program will crash but a program with any of the other modules will run on a system without Python.

"""
Created on Mon Jan  9 09:23:13 2017
@author: me
"""
import PyQt4
print("This program simply tests if a packaged\npython program runs on your system!\n")
input("Press Enter to exit...")

EDIT 2

An example of the terminal output when the program is built.

enter image description here

1
Could you create a minimal example application and pyinstaller script that shows the problem?Trilarion
Hi @Trilarion, please see above edit, thank youEoin
PyQt4 is not PySide. Your edited minimal program should never give that error with PySide. Also it should run, even when freezed with pyinstaller. Something else is going on. Can you follow these steps and these steps?Trilarion
Well aware of that thank you. Freezed program is running on my sytem but not on someones who doesn't have Python. I have tried editing the spec file to include the PyQt4 directory, have tried excluding PySide in the spec file. Scenarios were tried together and separately. Output indicates PyQt4 is found as the output shows module hooks for PyQt4, PyQt4.QtGui and PyQt4.QtCore being loaded.Eoin

1 Answers

1
votes

The resolution to this was to roll the Python version back to a 3.4 distribution.

Once the needed modules (PyQt4 and PyInstaller (v3.2)) were installed, PyInstaller was used without issue in the same way as before.

The resulting exe was able to run on both systems with and without Python with no errors.

Tracking of this issue for PyInstaller is here.

Thank you