Fix Python3 Cx_freeze package flashback/fail to execute and no module named ' Matplotlib.backends.backend_tkagg '

Source: Internet
Author: User

Cx_freeze is a good library to package Python as EXE, but it cannot be run after you pack some programs after installation

Solution Reference http://comments.gmane.org/gmane.comp.python.cx-freeze.user/1856

Reference: http://stackoverflow.com/questions/23920073/cx-freeze-error-python-34

When opened, appears:

python\lib\site-packages\cx_freeze\freezer.py:574'importlib/__init__.pyc'

Then open cmd and run the exe file on the command line

The error is as follows:

Traceback (most recent): File"C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line -,inch<module>exec (code, m.__dict__) File"forecast.py", line4,inch<module>File"C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line2214,inch_find_and_load File"C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line2189,inch_find_and_load_unlocked File"C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line321,inch_call_with_frames_removed File"C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line2214,inch_find_and_load File"C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line2203,inch_find_and_load_unlocked File"C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line1191,inch_load_unlocked File"C:\Python\32-bit\3.4\lib\importlib\_bootstrap.py", line1161,inch_load_backward_compatibleattributeerror:'Module' Objecthas no attribute'_fix_up_module'

The reason is that there is a bug, crooked Nuts said version bug, is trying to solve, actually has been solved.

Look at me:

To see your own python number of bits:

Import sys, platform>>> platform.architecture ('64bit')  WindowsPE')

Then http://www.lfd.uci.edu/~gohlke/pythonlibs/from the Universal warehouse #cx_freeze

Download the corresponding version:

Of course, first uninstall the MSI I installed earlier, as follows:

After downloading the library is the zip end, change to WHL end

Then open cmd, go to the file directory, using:

Then go to the Cx-freeze instance in the Python installation directory to try unsuccessfully,

The command is:

Python setup.py Build

Last run:

No problem at all, because I just lack the wx bag, I didn't pretend.

And the simplest setup.py file can be found here,

#-*-coding:utf-8-*-#a very simple setup script to create A single executable##hello.py is a very "Hello, world" type script which also displays the#environment in which the script runs##Run The build process by running the command ' Python setup.py build '##If Everything works well should find a subdirectory in the build#subdirectory that contains the files needed to run the script without Python fromCx_freezeImportSetup, Executableexecutables=[Executable ('hello.py')]setup (name='Hello', Version='0.1', Description='Sample Cx_freeze Script', Executables=executables)

It's over now, so happy.

In fact, I have a lot of things to write blog, no motivation, alas.

Can download in my Baidu cloud: a

I made a build and found out that I was going to use Python to paint:

' Matplotlib.backends.backend_tkagg '

Seems to solve a problem, but also to solve one.

Reference: Http://stackoverflow.com/questions/20582384/importerror-no-module-named-backend-tkagg

I've seen this before, also on OpenSUSE (12.3). The fix is to edit the default Matplotlibrc file. Here's how to find where the default Matplotlibrc file lives, and where it lives on my machine:>>>Importmatplotlib>>>Matplotlib.matplotlib_fname ()'/USR/LIB64/PYTHON2.7/SITE-PACKAGES/MATPLOTLIB/MPL-DATA/MATPLOTLIBRC'The backend setting isThe first configuration optioninchThis file. Change it fromTkagg to Agg,orTo some and backend you has installed on your system. The commentsinchThe MATPLOTLIBRC file list all backends supported by Matplotlib. The backend specifiedinchThis file isonly the default; You can still change it in runtime by adding the following the lines, before any other matplotlibImport:ImportMatplotlibmatplotlib.use ("Agg")#or whichever backend you wish

This means you can change the first configured Tkagg in SITE-PACKAGES/MATPLOTLIB/MPL-DATA/MATPLOTLIBRC to agg, or add the following at the beginning of the program:

Import Matplotlibmatplotlib.use ("Agg")  # or whichever backend you wish

Fix Python3 Cx_freeze package flashback/fail to execute and no module named ' Matplotlib.backends.backend_tkagg '

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.