pythonpyinstallerexchangelibzoneinfotzdata

exchangelib and pyinstaller - zoneinfo - tzdata - UTC issue


In my python project, I'm using exchangelib and I needed to create an exe file. Using pyinstaller --onefile I had UTC errors (in general tzdata)- "No timzone in key UTC". Simplifying all and following this issue https://github.com/ecederstrand/exchangelib/issues/897 I noticed that the issue was the same with this simple code:

from zoneinfo import ZoneInfo
utc = ZoneInfo('UTC')

I also tried with py2exe, cx_freeze, forcing tzdata import, same issue.

I spent a lot of time finding a workaround and I want to share my temporary solution but also discuss other alternative solutions.


Solution

  • This worked for me after exploring different options:

    pyinstaller --collect-all tzdata --onefile file_name.py

    PS: I have been facing this problem and reached here to explore about pyinstaller. Your solution works too but its a directory where as I wanted it to be exe.