[1] 代码是:
import Tkinter
from Tkinter import *
# Create Tk instance
root = Tkinter.Tk(className="test")
# Open Notepad
def openNotepad():
import pywinauto
app = pywinauto.Application.start("notepad.exe")
# Add menu
menu = Menu(root)
root.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label="01 File", menu=filemenu)
filemenu.add_command(label="New", command=openNotepad)
# Pack all
root.mainloop()
[2] 如果我双击 .py 文件,代码就会工作。
如果我只保留 openNotepad() 函数,那么 .exe 将起作用。
根据文档:https://github.com/pyinstaller/pyinstaller/wiki/Supported-Packages ,支持 pywinauto 库。
如果我只留下 Tkinter 片段,.exe 将起作用。
因此,请分享我做错了什么,或者请推荐其他适用于 python 2.7x 的 python 安装程序。
最佳答案
通过在文件\PyInstaller\hooks\hook-PIL.py 和 hook-PIL.SpiderImagePlugin.py 中注释掉开头为:excludedimports 的行,问题就解决了。
关于python --> pyinstaller - .exe 文件将返回 "test returned -1",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32968775/