ImportError: No module named win32timezone when i make a singleone exe from a python script with pyInstaller

I think you need to follow this section of the Pyinstaller manual:

https://pythonhosted.org/PyInstaller/#id67

Listing Hidden Imports

If Analysis thinks it has found all the imports, but the app fails with an import error, the problem is a hidden import; that is, an import that is not visible to the analysis phase.

Hidden imports can occur when the code is using import or perhaps exec or eval. Hidden imports can also occur when an extension module uses the Python/C API to do an import. When this occurs, Analysis can detect nothing. There will be no warnings, only an ImportError at run-time.

To find these hidden imports, build the app with the -v flag (Getting Python's Verbose Imports above) and run it.

Once you know what modules are needed, you add the needed modules to the bundle using the --hidden-import= command option, or by editing the spec file, or with a hook file (see Understanding PyInstaller Hooks below).


the -v flag no longer works (shows the version now).

First, find out which module is missing. You can do this by executing the exe through PowerShell/cmd. For example, if your file is "project.exe", open a PowerShell window in its directory and use the command: .\project.exe.

Use this to build the exe: pyinstaller --hiddenimport win32timezone -F a.py

  • win32timezone was the missing module.
  • Use either -F or --onefile to create a standalone, redistributable exe.
  • You can use --hiddenimport multiple times if you have multiple modules missing.

Reference: https://pythonhosted.org/PyInstaller/usage.html