-
Notifications
You must be signed in to change notification settings - Fork 9
[tip] using PyInstaller
Gord Thompson edited this page Dec 18, 2023
·
1 revision
SQLAlchemy's mechanism for loading third-party dialects appears to be incompatible with PyInstaller's default bundling of modules. If we have a "main.py" consisting of
import sqlalchemy_access as sa_a
print(sa_a.__version___)
and build "main.exe" using
pyinstaller main.py
then running the .exe prints the current version of sqlalchemy-access. However, if "main.py" tries to create a SQLAlchemy engine using
engine = create_engine("access+pyodbc://@my_dsn")
the .exe will throw an error:
Module not found error : no module named 'sqlalchemy_access.pyodbc'
The fix is to use PyInstaller's --collect-all
option to include all of the sqlalchemy_access files:
pyinstaller --collect-all sqlalchemy_access main.py