python --> pyinstaller - .exe file will return “test returned -1”

痞子三分冷 提交于 2019-12-10 22:45:21

问题


[1] The code is:

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.

If I leave only the openNotepad() function, then .exe will work.

According to docs: https://github.com/pyinstaller/pyinstaller/wiki/Supported-Packages, the pywinauto library is supported.

If I leave only the Tkinter snippet, the .exe will work.

Therefore please share what I am doing wrong or please suggest other python installer for python 2.7x.


回答1:


By commenting out the line starting with: excludedimports in files \PyInstaller\hooks\hook-PIL.py and hook-PIL.SpiderImagePlugin.py, the problem was solved.




回答2:


Try to replace every exit(), quit(), or os._exit() with 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



来源:https://stackoverflow.com/questions/32968775/python-pyinstaller-exe-file-will-return-test-returned-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!