ruby_rhod_on_rails
ruby_rhod_on_rails

Reputation: 105

Pyinstaller missing SqlAlchemy dlls

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.

Upvotes: 7

Views: 6347

Answers (2)

Jonathan Biemond
Jonathan Biemond

Reputation: 548

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

Upvotes: 1

user3801578
user3801578

Reputation: 141

i had a same issue earlier.. resolves this problem by importing sqlalchemy.sql.default_comparator on my main program..

Upvotes: 14

Related Questions