Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 752
ruby_rhod_on_rails Avatar asked Jan 31 '17 14:01

ruby_rhod_on_rails


2 Answers

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

like image 59
user3801578 Avatar answered Sep 20 '22 01:09

user3801578


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

like image 30
Jonathan Biemond Avatar answered Sep 18 '22 01:09

Jonathan Biemond