Missing pyexpat.dll

I wish to use pyinstaller to create an executable for my Python script. The executable is created, but the running of it crashes.

Traceback (most recent call last): 
File "PyInstaller\hooks\rthooks\pyi_rth_pkgres.py", line 170, in <module>
File "PyInstaller\hooks\rthooks\pyi_rth_pkgres.py", line 37, in _pyi_rthook 
File "PyInstaller\loader\pyimod02_importers.py", line 450, in exec_module 
File "pkg_resources\__init__.py", line 42, in <module> 
File "PyInstaller\loader\pyimod02_importers.py", line 450, in exec_module 
File "plistlib.py", line 70, in <module> 
File "PyInstaller\loader\pyimod02_importers.py", line 450, in exec_module 
File "xml\parsers\expat.py", line 4, in <module> 
ImportError: DLL load failed while importing pyexpat: 
The specified module could not be found.

with ChatGPT i concluded i miss pyexpat.dll on my computer.

I use Python 3.12.4 on a ‘64bit’ on ‘WindowsPE’. Python was installed as part of Anaconda3 and would like to prevend the solution “reinstall python”.

Any suggestions?

Kind regards,
Johannes

Try this python - ImportError: DLL load failed while importing pyexpat: The specified module could not be found - Stack Overflow

Or follow pyinstaller’s instructions:

Windows

The developer needs to take special care to include the Visual C++ run-time .dlls: Python 3.5+ uses Visual Studio 2015 run-time, which has been renamed into “Universal CRT“ and has become part of Windows 10. For Windows Vista through Windows 8.1 there are Windows Update packages, which may or may not be installed in the target-system. So you have the following options:

updating the C++ did not work as it could not update when a newer version already installed… not sure what the python instructions tell me, but ran an update with no succes afterwards, even after rebuidling the executable. Feel way out of my comfort zone with no clue what i am doing/ should be doing…

in python i can import pyexpat without any issues, even though the script doesn’t use it. Only when I create the executable with pyinstaller, the executable itself crashes and (suddenly) misses it.