0

I'm trying to generate an executable. the packages I am using are

import sys
import matplotlib.pyplot as plt
from pylab import *
from numpy import *  

the setup.py is the following

from distutils.core import setup
import py2exe
import matplotlib

setup(console=['<python file>'],data_files=matplotlib.get_py2exe_datafiles(),)   

but I get an error related to pyplot.pyc

Import Error: no module named backend_tkagg

any way around to fix it?

1

2 Answers 2

10

You should include the matplotlib module explicitly. If you do that you can get some errors from unavailable dlls, so then you should exclude them.
A setup that works for me with your file:

from distutils.core import setup
import py2exe
import matplotlib

setup(console=['afile.py'],
      options={
               'py2exe': {
                          'packages' :  ['matplotlib', 'pytz'],
                          'dll_excludes': ['libgdk-win32-2.0-0.dll',
                                         'libgobject-2.0-0.dll',
                                         'libgdk_pixbuf-2.0-0.dll',
                                         'libgtk-win32-2.0-0.dll',
                                         'libglib-2.0-0.dll',
                                         'libcairo-2.dll',
                                         'libpango-1.0-0.dll',
                                         'libpangowin32-1.0-0.dll',
                                         'libpangocairo-1.0-0.dll',
                                         'libglade-2.0-0.dll',
                                         'libgmodule-2.0-0.dll',
                                         'libgthread-2.0-0.dll',
                                         'QtGui4.dll', 'QtCore.dll',
                                         'QtCore4.dll'
                                        ],
                          }
                },
      data_files=matplotlib.get_py2exe_datafiles(),)   
Sign up to request clarification or add additional context in comments.

1 Comment

In order to get this to work, I had to add 'excludes':['zmq'] to the above script. Otherwise I'd get a "failed to find libzmq.pyd" when running executing my setup script.
1

I needed to add (python2.7):

    import sys
    sys.path.append("C:\\pathToYourPython\\pythonxy2731\\console\\Microsoft.VC90.CRT")

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.