Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7678677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:42:09+00:00 2026-05-31T17:42:09+00:00

I’m trying to make an executable using py2exe. My .py uses Tkinter, matplotlib and

  • 0

I’m trying to make an executable using py2exe. My .py uses Tkinter, matplotlib and something else:

import Tkinter
import math
from matplotlib.figure import Figure
from pylab import *
import random

The Setup.py I use to make my executable is the following:

 from distutils.core import setup
import py2exe


# We need to import the glob module to search for all files.
import glob

# We need to exclude matplotlib backends not being used by this executable.  You may find
# that you need different excludes to create a working executable with your chosen backend.
# We also need to include include various numerix libraries that the other functions call.

opts = {
    'py2exe': { "includes" : [
                               "matplotlib.figure","pylab", "numpy"],
                'excludes': ['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg', "matplotlib.numerix.fft","sip", "PyQt4._qt",
                             "matplotlib.backends",  "matplotlib.backends.backend_qt4agg",
                               "matplotlib.numerix.linear_algebra", "matplotlib.numerix.random_array",
                               "matplotlib.backends.backend_tkagg"
                             '_fltkagg', '_gtk','_tkagg','_gtkcairo' ],
                'dll_excludes': ['libgdk-win32-2.0-0.dll',
                                 'libgobject-2.0-0.dll']
              }
       }

# Save matplotlib-data to mpl-data ( It is located in the matplotlib\mpl-data
# folder and the compiled programs will look for it in \mpl-data
# note: using matplotlib.get_mpldata_info
data_files = [(r'mpl-data', glob.glob(r'C:\Python26\Lib\site-packages\matplotlib\mpl-data\*.*')),
                    # Because matplotlibrc does not have an extension, glob does not find it (at least I think that's why)
                    # So add it manually here:
                  (r'mpl-data', [r'C:\Python26\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']),
                  (r'mpl-data\images',glob.glob(r'C:\Python26\Lib\site-packages\matplotlib\mpl-data\images\*.*')),
                  (r'mpl-data\fonts',glob.glob(r'C:\Python26\Lib\site-packages\matplotlib\mpl-data\fonts\*.*'))]

# for console program use 'console = [{"script" : "scriptname.py"}]
setup(windows=[{"script" : "test.py"}], options=opts,   data_files=data_files)

Now, I make my executable, but when I run it, I get this list of errors:

Traceback (most recent call last):
File "test.py", line 17, in <module>
File "pylab.pyc", line 1, in <module>
File "matplotlib\pylab.pyc", line 259, in <module>
File "matplotlib\pyplot.pyc", line 94, in <module>
ImportError: No module named backends

I don’t know much about backends, I also tried not to exclude anything from the Setup.py file but I get the same error: “No module named backends”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:42:10+00:00Added an answer on May 31, 2026 at 5:42 pm

    I solved by slightly modifying the setup.py file used to create the executable:

    from distutils.core import setup
    import py2exe
    
    
    # We need to import the glob module to search for all files.
    import glob
    
    # We need to exclude matplotlib backends not being used by this executable.  You may find
    # that you need different excludes to create a working executable with your chosen backend.
    # We also need to include include various numerix libraries that the other functions call.
    
    opts = {
      'py2exe': { "includes" : ["matplotlib.backends.backend_tkagg"],
    
                    'excludes': ['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg', "matplotlib.numerix.fft","sip", "PyQt4._qt",
                                  "matplotlib.backends.backend_qt4agg",
                                   "matplotlib.numerix.linear_algebra", "matplotlib.numerix.random_array",
    
                                 '_fltkagg', '_gtk','_gtkcairo' ],
                    'dll_excludes': ['libgdk-win32-2.0-0.dll',
                                     'libgobject-2.0-0.dll']
                  }
           }
    
    # Save matplotlib-data to mpl-data ( It is located in the matplotlib\mpl-data
    # folder and the compiled programs will look for it in \mpl-data
    # note: using matplotlib.get_mpldata_info
    data_files = [(r'mpl-data', glob.glob(r'C:\Python26\Lib\site-packages\matplotlib\mpl-data\*.*')),
                        # Because matplotlibrc does not have an extension, glob does not find it (at least I think that's why)
                        # So add it manually here:
                      (r'mpl-data', [r'C:\Python26\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']),
                      (r'mpl-data\images',glob.glob(r'C:\Python26\Lib\site-packages\matplotlib\mpl-data\images\*.*')),
                      (r'mpl-data\fonts',glob.glob(r'C:\Python26\Lib\site-packages\matplotlib\mpl-data\fonts\*.*'))]
    
    # for console program use 'console = [{"script" : "scriptname.py"}]
    setup(windows=[{"script" : "test.py"}], options=opts,   data_files=data_files)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.