6
votes

I am trying to build my app with --onefile option by pyinstaller. Here is the extract.

import sys
from PyQt4 import QtGui, QtCore
from modules.login import Login

def main():
    app = QtGui.QApplication(sys.argv)
    app.setQuitOnLastWindowClosed(False)
    login = Login()
    login.show()
    sys.exit(app.exec_())


if __name__ == "__main__":
    main()    

I tried to build using:

 >pyinstaller --onefile app.py

Running the generated dist/app I get this error:

Traceback (most recent call last):
  File "<string>", line 36, in <module>
ImportError: No module named QtCore

I am building this from Ubuntu 13. Anyone with an idea why this is happening?

2
Try sudo apt-get install libqt4-dev - Padraic Cunningham
Running .. > libqt4-dev is already the newest version - Cheruiyot Felix
Yes.It is installed and I can run the program well before building with the Pyinstaller. - Cheruiyot Felix
which python version are you using? - Padraic Cunningham
I have decide to build everything from source. I will let you know the results> pyqt.sourceforge.net/Docs/PyQt4/… - Cheruiyot Felix

2 Answers

6
votes

There is a bug in the current version of PyInstaller that causes this problem. See this ticket for more details.

The good news is that it's been fixed. The bad news is that it's only arriving in PyInstaller 2.2. In the mean time, you could try installing a development build of PyInstaller to solve this issue.

0
votes

i just had a similar problem, once i ran pyinstaller --onedir main.py, i got that error.

i copied the Qt5core.dll in the same folder as the generated .exe to the \PyQt\bin folder and everything was working well.