首页 > 解决方案 > Python,CX 冻结错误,当我尝试启动我的 exe 时

问题描述

你好

我尝试学习 Python ......我自己做了一个小软件,用于从 XLSX 读取数据,当我通过“普通方式/python 方式”(在崇高文本中 ctrl + B)启动时,一切都运行良好。...但是...当我用“cx.freeze”编译它以获取我的“.exe”并启动我的.exe时,我得到这个错误窗口:

https://i.stack.imgur.com/E2GVw.png

我试过图书馆问我更新了我所有的图书馆,但什么也没有

这里是我的代码的开头和结尾,以及 PIP 安装的库:

# c-*- coding: utf-8 -*-
# Bibliotheques
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import openpyxl
import xlrd
import mpl_toolkits
import sys
import os
from tkinter import *
from tkinter import messagebox
from tkinter.filedialog import *  # askopenfilename
from functools import partial
from PIL import Image, ImageTk

class MyApp(Tk):  # --- Class.N°1 --- #
    def __init__(self):
        Tk.__init__(self)


if __name__ == '__main__':
    MyApp()

这里是我使用的 CX.freeze scrypt:


from cx_Freeze import setup, Executable
import os.path

PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')

base = "Win32GUI" #pour appli graphique ss windows
#base = "console" #pour appli console

options = {
   'build_exe': {
       'include_files':[
           os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
           os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
       ],
   },
}

# On appelle la fonction setup
setup(name = "GraphEditor",
   options = options,
   version = "V1.1.2",
   author = "Scorn",
   description = "Reading and editing trends from 2D table",
   executables = [Executable("GraphEditor.py",base=base, icon="xln.ico")]
)

所以我的问题是:为什么我有这个错误,我该如何解决?

谢谢你的时间和你的回答:)

标签: pythonpandasmatplotlibtkintercx-freeze

解决方案


我发现 CXFreeze 在很多情况下都不能很好地工作。所以我更喜欢使用Nuitka作为替代方案。使用起来非常简单。

nuitka --file-reference-choice=runtime --recurse-to=[some_module] main.py

我使用 Nuitka 冻结了一个非常大的 Python 应用程序(使用 NumPy 和 OpenGL 的集成 Web 服务器)。一些报告说编译 NumPy 时存在一些问题。但我认为熊猫会很好。


推荐阅读