Problem with python-markdown and pyinstaller

Using Pyinstaller or auto-py-to exe works fine until i try to use an extension

—> (IT = markdown.markdown(row[5], extensions=[‘tables’]))

it builds without problems ut on runtime i fail with:

File “C:\DROPBOX\PROJEKTE\DEVL_KOREG\tmkomo\browser_prep\Markup2HTM.py”, line 34, in kapi
IT = markdown.markdown(row[5], extensions=[‘tables’])
File “markdown\core.py”, line 386, in markdown
File “markdown\core.py”, line 96, in init
File “markdown\core.py”, line 123, in registerExtensions
File “markdown\core.py”, line 162, in build_extension
File “importlib_init_.py”, line 127, in import_module
File “”, line 1030, in _gcd_import
File “”, line 1007, in _find_and_load
File “”, line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named ‘tables’
[532] Failed to execute script ‘Markup2HTM’ due to unhandled exception!

IT = markdown.markdown(row[5]) works PERFECT but not for tables (;-))

thanks for helping me!

I don’t have any experience with PyInstaller, but here is my understanding of the problem. The markdown module tries to load extensions dynamically. There’s a list somewhere, and it does the equivalent of import foo for every foo in that list. This means that the modules being imported are only known at runtime, when the code is executed.

PyInstaller tries to discover the dependencies of your script ahead of time, by just looking at import statements in the source code. In this case, the imports are not spelled out explicitly because configuration changes or such could modify the list at runtime.

So you need to instruct PyInstaller about the dependency on the extension. For that, see

https://pyinstaller.readthedocs.io/en/stable/when-things-go-wrong.html#listing-hidden-imports

Thank you very much i will follow your path - but i am not sure if i have the necessary nowledge…