PyInstaller bundled app: Failing to get source code with exceptions
See original GitHub issueHey @Delgan,
I’m not too sure if this is a loguru or PyInstaller issue, but I figured I’d start here.
I’m still working on that app from my previous tickets and am running into an issue when it is bundled. When an exception occurs within the app while bundled (i.e. running from EXE), I am not seeing any source code being recorded by loguru from the exception. I tried this in a fresh environment (conda) with only loguru 0.5.3 and pyinstaller 4.0 the installed 3rd party libraries and got the same thing. I tried a different app with just a single, tiny file in both the original and new environment and still got the issue.
Here is an example output from the other application
2020-11-12 14:23:31.082 | INFO | __main__:main:5 - Here is a message
2020-11-12 14:23:31.084 | ERROR | __main__:<module>:10 - An error has been caught in function '<module>', process 'MainProcess' (8008), thread 'MainThread' (2504):
Traceback (most recent call last):
> File "main.py", line 10, in <module>
File "main.py", line 7, in main
ValueError: Test error
As you can see, this is the default configuration for loguru. Anyways, here is the source code:
from loguru import logger
@logger.catch
def main():
logger.info("Here is a message")
raise ValueError("Test error")
if __name__ == "__main__":
main()
Put that into a file named main.py
and then run the following command with pyinstaller:
pyinstaller main.py
Then run the bundled exe and it should produce the issue.
Let me know if there is anything else I can provide. Jules
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top GitHub Comments
@zhfkt Unfortunately I’m not aware of any solution without bundling data. As far as I know, the Python exception formatter needs the source file to retrieve and display the code lines.
Hello.
This looks very similar to this issue: #250 Can you confirm that this is the same problem?
It seems you need to the add the source code to the bundled application using
--add-data=main.py;.
.