使用Windows Power Shell将Tkinter py文件转换为EXE文件

时间:2020-06-25 13:07:30

标签: python powershell tkinter

我正在尝试使用Windows Power Shell将tkinter python文件转换为.exe。但是我遇到了错误。

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()
 

1 个答案:

答案 0 :(得分:0)

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

相关问题