The Quantum Physicist The Quantum Physicist - 1 year ago 107
Python Question

Get Python stack trace while using cx_freeze

I have a data acquisition program written in Python that I distribute to my collaboration as an executable (using cx_freeze), as I don't want to bother them with installing Python and installing all the software dependencies. The program has been working well for a year now. Recently, the program started to crash (crash, not give a scripting error, i.e., the Python virtual machine itself is crashing). So I would like to know what library is causing this problem. This problem is happening randomly, so it's difficult to systematically pinpoint the cause.

I learned about faulthandler, and I would like to use it with my cx_freeze, because I can't be sure the problem is happening due to cx_freeze itself or due to some other library.

The question: How can I produce a cx_freeze executable that will use


What I tried:

My current cx_freeze setup script is the following:

import sys
from cx_Freeze import setup, Executable
from GUI.Meta import *

target = Executable("",
#base = "Win32GUI",
icon = "GUI\\icon.ico",

name = "My Software",
description = "",
executables = [target])

I tried replacing my Executable part
by -q -X faulthandler
, but that didn't work. Importing
in my cx_freeze setup file with
import faulthandler
from faulthandler import *
didn't help.

Please advise.

Additional info: Dependencies that I'm using (in case you may know a possible cause of the problem): PySide, Sympy, Numpy, H5py, PySerial, Matplotlib

Answer Source

I learned that I could use procdump. It can be downloaded from here. It's a very simple program that can log stack trace. You can use it with:

C:\>procdump -ma -i c:\Dumps

and this will dump the stack trace of any program that crashes to that folder.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download