Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 消息无法执行脚本_Python_Tkinter_Exe_Pyinstaller - Fatal编程技术网

Python 消息无法执行脚本

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

我编写了一个将docx转换为pdf的脚本

我用tkinter做了一个简单的表单

当我尝试使用以下命令生成exe文件时:

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