1
votes

I am using Pyinstaller (after spending a long time with py2exe) to convert my REAL.py file to .exe. I used Anaconda to make .py file which is running perfectly on my computer. But when I make .exe file, it shows no error and an application is created in dist\REAL folder. But when I run the .exe file, the console opens and closes instantly.

It should ideally show a GUI window and take inputs and use them to make plots. It does so when I run REAL.py file. I am using Tkinter, Matplotlib, numpy, scipy which comes with Anaconda.

EDIT: I tried to run simple code to check the compatibility with matplotlib:

import matplotlib.pyplot as plt

plt.plot([1,2,3,4])

plt.ylabel('some numbers')

plt.show()

The same issue persists with this. Opens console window and then closes but no plot is given out.

2
I'm having a similar problem. One thing that you might want to try is using the '--debug' flag as an argument to pyinstaller - it may help you identify what the specific failure is. - user888379

2 Answers

1
votes

I found the solution in py2exe. Following was the setup.py file that worked with Tkinter Matplotlib numpy scipy imports:

from distutils.core import setup
import py2exe

from distutils.filelist import findall
import matplotlib

opts = {"py2exe": {
    "packages" : ['matplotlib'],
    "includes": ['scipy', 'scipy.integrate', 'scipy.special.*','scipy.linalg.*'],
         'dll_excludes': ['libgdk-win32-2.0-0.dll',
                            'libgobject-2.0-0.dll',
            'libgdk_pixbuf-2.0-0.dll']
                     }
           }

setup(
      windows = [{'script': "with_GUI.py"}], zipfile = None,
      options= opts,
      data_files = matplotlib.get_py2exe_datafiles()
     )

But this gave me some error saying that there was version conflict with two files. So I changed the two files viz. dist/tcl/tcl8.5/init.tcl (in line 19) and dist/tcl/tk8.5/tk.tcl (in line 18). In my case I changed the version from 8.5.15 to 8.5.18. I found the location of the two files by looking at the path specified by the error in error log. Then the .exe worked just fine.

I hope this helps.

0
votes

Try using the --hidden-import=matplotlib when calling pyinstaller. For example, in the command prompt you would type:

Pyinstaller --hidden-import=matplotlib your_filename_here.py

and you could try giving it a shot with tkinter in there as well.

Pyinstaller --hidden-import=matplotlib --hidden-import=tkinter your_filename_here.py