import sys
from PyQt4.QtCore import SIGNAL
from PyQt4.QtGui import QMainWindow, QPushButton, QApplication
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.btn1 = QPushButton("Click me", self)
if len(sys.argv) > 1:
self.connect(self.btn1, SIGNAL("clicked()"), self.doit) # No crash
else:
self.btn1.clicked.connect(self.doit) # Crash
def doit(self):
print "Click"
if __name__ == "__main__":
app = QApplication(sys.argv)
myapp = MainWindow()
myapp.show()
sys.exit(app.exec_())
I am converting a PyQt application to exe on Windows and noticed a crash when running the generated exe where the debugger breaks at PyUnicodeUCS2_AsASCIIString.
this works fine in pure python 3.5 64-bit on Windows 10 and Qt5. how did you compile to executable? did you use setup.py or did you build the generated .C file (with --embed flag to Cython) from VS?
cython --embed app.py
cl app.c /IC:\Python27\include /link /libpath:C:\Python27\libs
Hopefully some Windows user can reproduce and debug this. Do you have a full backtrace that leads to the crash? I am really scratching my head as to what we could be doing to cause this...
> python27.dll!PyUnicodeUCS2_AsASCIIString() + 0x4 bytes
[Frames below may be incorrect and/or missing, no symbols loaded for python27.dll]
sip.pyd!00007ffc3d67b5f6()
QtCore.pyd!initQtCore() + 0x110dff bytes
QtCore.pyd!initQtCore() + 0x111320 bytes
python27.dll!PyCFunction_Call() + 0x76 bytes
app.exe!initapp() + 0x2fc5 bytes
app.exe!initapp() + 0x321d bytes
app.exe!initapp() + 0x30cb bytes
app.exe!00007ff651bf23fb()
app.exe!00007ff651bf1026()
app.exe!initapp() + 0x5251 bytes
app.exe!initapp() + 0x5340 bytes
app.exe!initapp() + 0x50aa bytes
python27.dll!PyObject_Call() + 0x65 bytes
python27.dll!PyMethod_New() + 0x911 bytes
python27.dll!PyObject_Call() + 0x65 bytes
python27.dll!PyType_Ready() + 0x2c5e bytes
python27.dll!PyType_ClearCache() + 0x206 bytes
app.exe!initapp() + 0x2fc5 bytes
app.exe!initapp() + 0x5df2 bytes
app.exe!initapp() + 0x1710 bytes
app.exe!initapp() + 0x6696 bytes
app.exe!initapp() + 0x78eb bytes
kernel32.dll!BaseThreadInitThunk() + 0xd bytes
ntdll.dll!RtlUserThreadStart() + 0x1d bytes
Don't you need also to link against Qt library?
Pyinstaller, cx_freeze, and most likely nuitka come with special hooks for this. At least these tools analyze for dependencies.
There is pyqt disutils tools available to handle just this:
https://pypi.python.org/pypi/pyqt-distutils
Not sure how to do this from VS or command-line cl.exe.
--
---
You received this message because you are subscribed to a topic in the Google Groups "cython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cython-users/Faxs4WWHGrg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cython-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Don't you need also to link against Qt library?
https://www.microsoft.com/en-us/download/details.aspx?id=44266
You are using VS 2010 and so mixing likely incompatible MSVC(++) runtimes.
```
import sys
#from PyQt4.QtCore import SIGNAL
from PyQt5.QtCore import pyqtSignal as SIGNAL
#from PyQt4.QtGui import QMainWindow, QPushButton, QApplication
from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication
print('imports done')
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.btn1 = QPushButton("Click me", self)
if len(sys.argv) > 1:
self.connect(self.btn1, SIGNAL("clicked()"), self.doit) # No crash
else:
print('before crash')
self.btn1.clicked.connect(self.doit) # Crash
def doit(self):
print("Click")
```
http://siomsystems.com/mixing-visual-studio-versions/
I'm not sure if this helps, but someone recompiled Python 2.7 with VS 2010 and VS 2015:
http://www.p-nand-q.com/python/building-python-27-with-visual_studio.html
This doesn't mean that it passes all CPython tests and has the same level of support like with VS 2008.
Another reason to upgrade to Python 3.4+ !
You can also use compatible mingw(py) instead of MSVC to build extensions, but not with Python 3.5+ due to UCRT issues.