I'm at a dead end ((I made a program in PyCharm, everything works. I compiled a python code into a binary using cx_Freeze. Everything works until I run a part of the script written using the docxtpl library, after which the process crashes or messages. In this part of the program, the script must process the word file template and save the created new file to disk.

def buttonClicked_docmaker(self): self.doc = DocxTemplate("template_AI.docx") self.context = {'factory_number': self.fgi.zavnumber} self.doc.render(self.context) self.doc.save("D:\\AI.docx") 

How can you organize the interception of such system errors in the source code to find the cause?

  • Check the link on the pyd files of this module. I didn’t get some cs library - eri
  • @eri tell me pliz which file to look for? in the folder with the program 64 of the .pyd file and there is not one with the name docxtpl, I am confused - Uglugbek

1 answer 1

Specifically, this error was in the shit coder, i.e. in my! Instead of the expected "template_AI.docx" I had the file "template_AI.doc"

But at the core of the question: How to intercept an error in a binary? until the answer - no way.

  • And add log_uncaught_exceptions to the code and try them to catch the error: github.com/gil9red/SimplePyScripts/blob/… . Or, try in the method where the error occurred to put try / except, most likely you have an error somewhere in the slot - gil9red
  • IMHO, you just need to enable logging. And handle all exceptions - Viktorov