简体   繁体   English

python --> pyinstaller - .exe 文件将返回“测试返回 -1”

[英]python --> pyinstaller - .exe file will return "test returned -1"

[1] The code is: [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] The code works if I double click on .py file. [2] 如果我双击 .py 文件,代码就可以工作。

If I leave only the openNotepad() function, then .exe will work.如果我只保留 openNotepad() 函数,那么 .exe 将起作用。

According to docs: https://github.com/pyinstaller/pyinstaller/wiki/Supported-Packages , the pywinauto library is supported.根据文档: https : //github.com/pyinstaller/pyinstaller/wiki/Supported-Packages ,支持 pywinauto 库。

If I leave only the Tkinter snippet, the .exe will work.如果我只留下 Tkinter 代码段,.exe 将起作用。

Therefore please share what I am doing wrong or please suggest other python installer for python 2.7x.因此,请分享我做错了什么,或者请为 python 2.7x 推荐其他 python 安装程序。

通过注释掉以下开头的行:excludedimports in files \\PyInstaller\\hooks\\hook-PIL.py 和 hook-PIL.SpiderImagePlugin.py,问题就解决了。

Try to replace every exit() , quit() , or os._exit() with sys.exit() .尝试更换每一个exit() quit()os._exit()sys.exit() I see that you don't have any of these in your code but somebody else might find this advice to be useful.我看到您的代码中没有任何这些内容,但其他人可能会发现此建议很有用。

My versions: python3.4, pyinstaller3.1.1我的版本:python3.4、pyinstaller3.1.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM