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 warnmain.txt
file in the build
directory: warnmain.txt
I don't really understand those warnings, for example "no module named numpy.pi" since numpy.pi
is no module but a number. I never tried to import numpy.pi
. I did import numpy
and matplotlib
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):
QtGui.QMainWindow.__init__(self)
self.pb = QtGui.QPushButton(str(np.pi), self)
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())
Successfully here means that the created executable file actually showed the desired output. However there is also a warnmain.txt
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. hook-matplotlib
was executed. I could not see any hook for numpy
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
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.
import numpy.sinh
I getImportError: No module named sinh
and it is only when I doimport numpy.numpy.sinh
that I getImportError: No module named numpy.sinh
. Have you checked PyInstaller finding out what went wrong? to grab errors / verbose imports / debug info?-w
(see pythonhosted.org/PyInstaller/#options-for-the-executable-output ) which prevents Windows from launching a console for any input/output. If I'd compile without-w
I cannot get the graphical user interface. However the program works fine when invoking from the interpreter, so I don't think it's an error inside. @ssnobody: I'm aware of that link but it didn't bring any benefits for me.import numpy.sinh
won't work sincesinh
is no module.-w
and get the GUI. However if I do I get a console where I can see for a very short moment (far to short to actually read) that something's written there, but then the application terminates. The GUI does not appear. I try to get this stdout somehow to a file so I can actually read it.