Python 消息无法执行脚本
我编写了一个将docx转换为pdf的脚本 我用tkinter做了一个简单的表单 当我尝试使用以下命令生成exe文件时:Python 消息无法执行脚本,python,tkinter,exe,pyinstaller,Python,Tkinter,Exe,Pyinstaller,我编写了一个将docx转换为pdf的脚本 我用tkinter做了一个简单的表单 当我尝试使用以下命令生成exe文件时: pyinstaller --onefile converter.py pyinstaller --noconsole converter.py 我还尝试了以下命令: pyinstaller --onefile converter.py pyinstaller --noconsole converter.py 执行脚本转换器失败时出现错误 import os impo
pyinstaller --onefile converter.py
pyinstaller --noconsole converter.py
我还尝试了以下命令:
pyinstaller --onefile converter.py
pyinstaller --noconsole converter.py
执行脚本转换器失败时出现错误
import os
import tkinter as tk
from docx2pdf import convert
from tkinter.messagebox import showinfo
from tkinter.filedialog import askopenfilenames
def openfile():
try:
files = askopenfilenames(filetypes=[('word file', '*docx')])
for file in files:
convert(file, str(os.path.dirname(file)))
showinfo('Done', 'Files converted')
except Exception as e:
print('Error', e)
def main():
win = tk.Tk()
label = tk.Label(win, text='Choose file: ')
label.grid(row=0, column=0, padx=5, pady=5)
button = tk.Button(win, text='Select', width=30, command=openfile)
button.grid(row=0, column=0, padx=5, pady=5)
win.mainloop()
if __name__ == '__main__':
main()