首页 > 解决方案 > 使用 windows power shell 将 Tkinter py 文件转换为 EXE 文件

问题描述

我正在尝试将我的tkinterpython 文件转换为.exe使用 windows power shell。但我得到了错误。

RecursionError:超出最大递归深度

我的源代码。

from tkinter import *
from tkinter.filedialog import askopenfile
from openpyxl import load_workbook
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib import rcParams
# figure size in inches
rcParams['figure.figsize'] = 5,6
root = Tk()
root.geometry('400x400')
def open_file():
    file = askopenfile(mode ='r', filetypes =[('Excel Files', '*.xlsx')])
    print(file)
    print(type(file))
    print(file.name)
    
    data=pd.read_excel(file.name)
    print(pd.crosstab(data["Sex"],data.Survived))
    ax = sns.countplot(x = 'Sex', hue = 'Survived', palette = 'Set1', data = data)
    ax.set(title = 'Total Survivors According to Sex', xlabel = 'Sex', ylabel='Total')
    plt.show()
    wb = load_workbook(filename = file.name,read_only=True) # Load into openpyxl
    wb2 = wb.active
    #Whatever you want to do with the WorkSheet
btn = Button(root, text ='Open excel sheet', command = open_file)
btn.pack(side='top')
#btn.pack(side='bottom')
root.mainloop()
 

标签: pythonpowershelltkinter

解决方案


我假设您需要将 Python 文件转换为 EXE。如果是这样,有很多库可用于将您的 python 文件转换为 EXE 文件。我使用的最好的一个是 PyInstaller。你可以试试。有关更多信息,请参阅此链接:https ://datatofish.com/executable-pyinstaller/


推荐阅读