1

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.

1
  • 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. Commented Mar 3, 2016 at 20:05

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Girish - can you please advise on how you used a setup.py file? Am just trying to figure out how to make this work with a pyinstaller command.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.