a_guest a_guest - 17 days ago 7x
Python Question

PyInstaller - no module named

I try to compile a Python project under Windows 7 using PyInstaller. The project works fine, there are no issues, however when I try to compile it the result doesn't work. Though I get no warnings during compilation there are many in the

file in the
directory: warnmain.txt

I don't really understand those warnings, for example
no module named numpy.pi
is no module but a number. I never tried to import
. I did import
explicitly. In addition I'm using PyQt4. I thought the error might be related to those libraries.

However I was able to compile a simple script which uses numpy succesfully:

import sys
from PyQt4 import QtGui, QtCore
import numpy as np

class MainWindow(QtGui.QMainWindow):
def __init__(self):

self.pb = QtGui.QPushButton(str(np.pi), self)

app = QtGui.QApplication(sys.argv)
main = MainWindow()

Successfully here means that the created executable file actually showed the desired output. However there is also a
file created which contains exactly the same 'warnings' as the one before. So I guess the fact that compiling my actual project does not give any success is not (or at least not only) related to those warnings. But what else could be the error then? The only output during compilation are 'INFO's and none of the is a negative statement.

I did not specify an additional hook directory but the hooks where down using the default directory as far as I could read from the compile output, e.g.
was executed. I could not see any hook for
neither could I for my small example script but this one worked. I used the following imports in my files (not all in the same but in different ones):

import numpy as np
import matplotlib.pyplot as ppl
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
from PyQt4 import QtGui, QtCore
import json
import sys
import numpy # added this one later
import matplotlib # added this one later

Does anyone know what this issue could be related to? Since PyInstaller does not give any errors/warnings I could not figure out if the problem is related to the libraries or if there is something else to be considered.

UPDATE: After the suggestion of JoranBeasley I compiled the program without
and redirected the stdout and stderr to a file. When executing the program I got the following

no module named Tkinter # seemed to be required by matplotlib

and after adding
import Tkinter
at the beginning of my main file I got

no module named FileDialog # seemed to be required also by matplotlib

and after I finally added
import FileDialog
the program actually works!


The problem were some runtime dependencies of matplotlib. So the compiling was fine while running the program threw some errors. Because the terminal closed itself immediately I didn't realize that. After redirecting stdout and stderr to a file I could see that I missed the libraries Tkinter and FileDialog. Adding two imports at the top of the main solved this problem.