Packaging with pyinstaller: PyQt4 module not found
Hello everyone and thanks for reading. I am packaging my python code into one file using pyinstaller, but when I run my packed file I get the following error:
Traceback (most recent call last):
File "<string>", line 21, in <module>
File "C:\Users\****\Desktop\pyinstaller-2.0\pyinstaller-2.0\PyInstaller\loader\iu.py", line 409, in importHook
ImportError: No module named PyQt4.QtCore
I don't know what this error says, especially since there is no dir name pyinstaller-2.0 on my desktop and I haven't used PyQt4 at all.
Imported modules: Tkinter, tkFileDialog, tkMessageBox, multiprocessing, os, sys, time, numpy, scipy.weave, pywt, matplotlib.pyplot
I think the problem is related to multiprocessing
since I haven't experienced this error before. I used this recipe in order to implement the module correctly multiprocessing
.
source to share
If you've used PyQt
, then the only way to import modules from PyInstaller is to use
from PyQt4 import QtCore, QtGui
but not
import PyQt4.QtCore, PyQt4.QtGui
what your error implies. However, you say you don't PyQt
.
PyQt
is an optional dependency matplotlib
, so there is a possibility that PyInstaller is checking the module matplotlib
and therefore including PyQt
.
I would suggest excluding the module PyQt
from assembly; in your .spec
file, look for the line for the class Analysis
- something like
Analysis( ..., excludes=['PyQt4', 'PyQt4.QtCore', 'PyQt4.QtGui'])
and edit the arg keyword excludes
as suggested above.
source to share