I am using Pyinstaller to compile Python to a standalone executable. The sourcecode includes modules PySide and SqlAlchemy. The dist .exe that PyInstaller creates runs OK, but when I run commands that access the database I get this error code in the command prompt:
Traceback (most recent call last):
File "clipper_tree.py", line 1907, in add_tree
File "build\bdist.win-amd64\egg\sqlalchemy\sql\operators.py", line 304, in __eq__
File "build\bdist.win-amd64\egg\sqlalchemy\orm\attributes.py", line 175, in operate
File "build\bdist.win-amd64\egg\sqlalchemy\sql\operators.py", line 304, in __eq__
File "build\bdist.win-amd64\egg\sqlalchemy\orm\properties.py", line 270, in operate
File "build\bdist.win-amd64\egg\sqlalchemy\sql\annotation.py", line 95, in __eq__
File "build\bdist.win-amd64\egg\sqlalchemy\sql\operators.py", line 304, in __eq__
File "build\bdist.win-amd64\egg\sqlalchemy\sql\elements.py", line 686, in operate
File "build\bdist.win-amd64\egg\sqlalchemy\sql\operators.py", line 304, in __eq__
File "<string>", line 1, in <lambda>
File "build\bdist.win-amd64\egg\sqlalchemy\sql\type_api.py", line 62, in operate
File "build\bdist.win-amd64\egg\sqlalchemy\util\langhelpers.py", line 964, in __getattr__
File "build\bdist.win-amd64\egg\sqlalchemy\util\langhelpers.py", line 962, in __getattr__
ImportError: Could not resolve module sqlalchemy.sql.default_comparator
While compiling, the command prompt output a few warnings about not being able to find "hidden DLLs" relating to sql alchemy. It said it was removing sqlalchemy/test files in response. Any help here would be deeply appreciated.
i had a same issue earlier.. resolves this problem by importing sqlalchemy.sql.default_comparator on my main program..
As @fredpi says you can add the module to the hiddenimports
parameter of the Analysis
initializer in the .spec file of the python file your trying to compile. Like so: hiddenimports=['sqlalchemy.sql.default_comparator']
Make sure you pass the .spec file when you run pyinstaller, or it will overwrite the .spec file and your changes will be lost. For example: pyinstaller --onefile myscript.spec
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With