CENTOS7/REDHAT7 Python3 use Cx-freeze packaging matplotlib programs encountered problems and solutions

Source: Internet
Author: User

Toss a day to meet a few headache problem, fortunately go back before the settlement lost

The first: Execute Cxfreeze packaged program encountered Tkinter and _tkinter missing issues

First Terminal: Python tkinter

Python _tkinter

Print (Tkinter)

Print (_tkinter)

Locate the two packages and copy them to the Cxfreeze packaged directory

The next step is to prompt:

First look at the system has not installed TK tcl. No words: yum-y install tkinter tcl-devel tk-devel

If there is.

import tkinter

root = tkinter.Tk()

print(root.tk.exprstring(‘$tcl_library‘))

print(root.tk.exprstring(‘$tk_library‘))

Find the installation location of Tcl and TK

Add such a few words to the setup.py:

os.environ[' tcl_library '] = "usr/share/tcl8.5"
os.environ[' tk_library '] = "usr/share/tk8.5"

os.environ[" TKPATH ] =" usr/share/tk8.5 "

RePack python setup.py Install

Run the executable program again to error:

This time even the error message is not very uncomfortable, tossing an afternoon almost give up, the last chance to find is the problem of the path, packaged file path name contains "document/" contains Chinese characters

Try to change a plain English path name success!

Then encountered a more uncomfortable problem, matplotlib program in the Linux terminal execution, no desktop environment, error:

Workaround:

Import Matplotlib.pyplot as plt followed by a sentence plt.switch_backend ("agg")
Test on a local virtual machine to view and close the Centos7 graphical interface:

To view the default target, execute: systemctl get-default Boot in command mode, execute: systemctl set-default multi-user.target boot with graphical interface, execute: SYSTEMCTL Set-default Graphical.target

Problem solving, a painful and happy day

CENTOS7/REDHAT7 Python3 use Cx-freeze packaging matplotlib programs encountered problems and solutions

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.