question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing exception log data when using pyinstaller

See original GitHub issue

I’m using loguru in one of my projects while using pyinstaller to create an EXE to run it on several Windows machines. I noticed some log data missing from exceptions when running the EXE. Here is an example of what I’m seeing.

# test.py

from loguru import logger

logger.add('test.log')

def div(n, d):
    try:
        return n / d
    except Exception as e:
        logger.exception(e)

div(2, 0)

When running this from the terminal it will produce this log file as expected.

2020-04-20 12:46:32.123 | ERROR    | __main__:div:9 - division by zero
Traceback (most recent call last):

  File "test.py", line 11, in <module>
    div(2, 0)
    └ <function div at 0x7f81f5ee43b0>

> File "test.py", line 7, in div
    return n / d
           │   └ 0
           └ 2

ZeroDivisionError: division by zero

But once you use pyinstaller (pyinstaller test.py -F) and run the resulting EXE this is what is in the log file.

2020-04-20 12:45:19.427 | ERROR    | __main__:div:9 - division by zero
Traceback (most recent call last):

  File "test.py", line 11, in <module>

> File "test.py", line 7, in div

ZeroDivisionError: division by zero

I have been able to reproduce this with python 3.8 on Windows 10 and python 3.7 on Fedora 30 using loguru==0.4.1 & PyInstaller==3.6

Not sure if this is an pyinstaller issue or a loguru issue, trying here first.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

When Things Go Wrong — PyInstaller 5.7.0 documentation
PyInstaller sometimes terminates by raising a Python exception. In most cases the reason is clear from the exception message, for example “Your system...
Read more >
Missing dll files when using pyinstaller - python - Stack Overflow
Show activity on this post. I'm using Windows 10 and had to delete the data in the C:\Users<username>\AppData\Local\pyinstaller directory and ...
Read more >
got error after compiled my python script with pyinstaller #929
I tried strace -e trace=stat and I just got a huge log telling me lots of files are missing...
Read more >
Using PyInstaller to Easily Distribute Python Applications
In this step-by-step tutorial, you'll learn how to use PyInstaller to turn your ... Often, you'll see ImportError exceptions if a dependency is...
Read more >
Packaging PyQt5 applications for Windows, with PyInstaller ...
Window with icon missing. The icons don't appear. What's happening? We're using relative paths to refer to our data files. These paths are ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found