Creating exe file with cx_Freeze, PyQt4, matplotli

2019-02-19 09:22发布

问题:

I'm currently struggeling to build my python project with cx_Freeze into an exe file and I'm not sure what I did wrong as I used the examples (PyQt4 and matplotlib) of Anthony Tuininga (https://github.com/GreatFruitOmsk/cx_freeze/tree/finder_zip_pkgs/cx_Freeze/samples) to do that.

I have three .py files, one main file, one ui file and one functions file. And of course the setup.py file.

I import only these packages in my files:

from PyQt4 import QtCore, QtGui
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

I use Python 3.4.3 64-bit (from mini conda) matplotlib 1.5.1, cx_Freeze 4.3.4 64-bit and Windows 10 64-bit

My setup.py file looks like this:

from cx_Freeze import setup, Executable
buildOptions = dict(packages=["atexit"],
#I also tried this one: #packages=["PyQt4.QtGui","PyQt4.QtCore","matplotlib"], 
#and instead of matplotlib, I also tried this one #"matplotlib.backends.backend_qt4agg"
                    excludes=["Tkinter"],
                    include_files=["Factory.ico","Main_Functions.py","Main_Ui.py"])
base = 'Win32GUI'
executables = [
    Executable('Main.py', base=base,icon="Factory.ico",compress = True)
]

setup(name="Simulator",
      version="0.0.1",
      description="NA",
      author="NA",
      author_email="NA",
      options=dict(build_exe=buildOptions),
      executables=executables)

The build process runs through without any errors (at least I don't find any) but once I want to start the application, I get the following error message which I don't understand as the directory C:\Python does not exists. I have also seen that others have the same problem but their solution did not worked for me or I did it wrong.

Could you please help me with this as I don't know what else to do and I'm getting a bit frustrated :( Thank you very much in advance :)