ModuleNotFoundError: traceback

101 views
Skip to first unread message

Xavier Nunn

unread,
Mar 15, 2023, 6:31:17 AM3/15/23
to PyInstaller
Hello!

I have been trying to compile a python application into a binary using pyinstaller. The result seems to compile just fine, there are no error messages during compilation. However, when running the resulting binary I get:

(...)
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "cli/cli.py", line 5, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "cli/main.py", line 9, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "anyio/__init__.py", line 89, in <module>
  File "PyInstaller/loader/pyimod02_importers.py", line 352, in exec_module
  File "anyio/_core/_exceptions.py", line 1, in <module>
ModuleNotFoundError: No module named 'traceback'

I don't understand how this can happen, since traceback is part of the standard library? I have even tried a version where I remove references to traceback in anyio (by editing the locally downloaded code) but I just get the same error in another place where traceback gets imported.

The compilation command I run has absolutely no extra options set, just:
pyinstaller entrypoint.py

I am lost here. Any pointers on how I could debug this?

Thanks!

Eric Fahlgren

unread,
Mar 15, 2023, 1:01:21 PM3/15/23
to pyins...@googlegroups.com
Even if a module is in the stdlib, it might not be included if it is not referenced somewhere (pyinstaller attempts to make the resulting binary as small as possible by only including what is needed).  That appears to be the case here, so '--hidden-import' is a likely solution.  Try

pyinstaller --hidden-import traceback entrypoint.py

and see if that gets you any farther...

Eric

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/f5d71120-bb21-453c-9913-e4d4cb6b566dn%40googlegroups.com.

Xavier Nunn

unread,
Mar 15, 2023, 1:10:22 PM3/15/23
to pyins...@googlegroups.com
Thank you for the quick reply!

Sadly, no luck, this doesn’t change the result, I get the same exact error.

Xavier

You received this message because you are subscribed to a topic in the Google Groups "PyInstaller" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyinstaller/x55gd_JD9Ow/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/CAP2Qz%2BUhxR_BFf3ThfBOiuwbUM8k4KSr7OkaYeB7%3DtuD0kiu1w%40mail.gmail.com.

Eric Fahlgren

unread,
Mar 16, 2023, 3:53:56 AM3/16/23
to pyins...@googlegroups.com
Ok, I probably should have asked this first: how exactly are you running the executable?  Are you moving any of the binary outputs to a different location (specifically the entrypoint.exe file)?

It's possible all you need to do is package using '--onefile' and then you won't have to worry about all the files in the dist/ directory at all...

pyinstall --onefile entrypoint.py

Xavier Nunn

unread,
Mar 16, 2023, 4:45:29 AM3/16/23
to pyins...@googlegroups.com
Right now, I am not moving the output of pyinstaller, I’m just running it from the output folder. My goal is to deploy the binary (or folder of files, I have no preference here) to other servers.

I have tried one-file and one-directory options, I get exactly the same result from both. I have also tried adding the site-packages folder used by my python install explicitly, using the -p option. Again, no luck.

Reply all
Reply to author
Forward
0 new messages