简体   繁体   中英

PySide “hello world”: py2exe/pyinstaller/cx_freeze and access violation

I am trying to build a very basic executable (Windows) using PySide. The following script runs properly in the interpreter (Python 2.7, PySide 1.1.2)

#!/usr/bin/python

import sys

sys.stdout = open("my_stdout.log", "w")
sys.stderr = open("my_stderr.log", "w")

import PySide.QtGui
from PySide.QtGui import QApplication
from PySide.QtGui import QMessageBox


# Create the application object
app = QApplication(sys.argv)

# Create a simple dialog box
msgBox = QMessageBox()
msgBox.setText("Hello World - using PySide version " + PySide.__version__)
msgBox.exec_()

I tried 3 methods (py2exe, pyinstaller and cx_freeze) and all the 3 generated executables fail to execute. The two stdout/stderr files appear, so I found the first PySide import is making everything fail. (Unhandled exception/Access violation)

I analyzed the executable file with depends ( http://www.dependencywalker.com/ ) and everything looks correctly linked.

Any idea?

You need to add the atexit module as an include. source: http://qt-project.org/wiki/Packaging_PySide_applications_on_Windows

(is also the case for Linux btw)

Thank you for your help. Actually, this did not change anything :/ However, I found a solution to my problem: if I add from PySide import QtCore, QtGui , then the executable (with pyinstaller) does work!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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