5

I compiled .py file with pyinstaller as follows:

pyinstaller --hidden-import presto --hidden-import scipy._lib.messagestream  --onefile main.py

When I ran the compiled file, I got the error:

sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:presto

p.s. I used sqlalchemy.engine to connect to presto like:

engine = create_engine('presto://presto.service.example.com:8080/hive/default')

I haven't found anything useful on google.

Piotr Leniartek
  • 1,177
  • 2
  • 14
  • 33
nullne
  • 511
  • 6
  • 12
  • The error doesn't occur if you run `main.py` without compiling? – SuperShoot Nov 19 '18 at 06:32
  • @SuperShoot no error occurs when running the script directly – nullne Nov 19 '18 at 06:55
  • 2
    Are you sure `--hidden-import presto` is correct? Seems like the DB-API driver is provided by [PyHive](https://pypi.org/project/PyHive/). The package [`presto`](https://pypi.org/project/presto/) in pypi seems unrelated. – Ilja Everilä Nov 19 '18 at 07:18
  • @IljaEverilä yes you are right, I tried many different packages as hidden import, but failed, including pyhive – nullne Nov 19 '18 at 09:02
  • This might also have something to do with how 3rd party dialects are [registered using entry points](https://github.com/zzzeek/sqlalchemy/blob/master/README.dialects.rst). Perhaps pyinstaller requires some hand holding with that? – Ilja Everilä Nov 19 '18 at 09:16
  • @IljaEverilä still have no idea of how : – nullne Nov 19 '18 at 11:49

2 Answers2

0

I had a similar issue with Teradata :

To get the Teradata Queries to run on the .exe produced by Pyinstaller. I changed my engine from SQLAlchemy to Teradata

From :

import sqlalchemy as sa
user, pasw, hostname = UserName,Password, 'myurl.com'
# connect
td_engine = sa.create_engine('teradata://{}:{}@{}:22/'.format(user,pasw,hostname),echo=True)
df = pd.read_sql_query(query1,connect)

To:

import teradata
user, pasw, hostname = UserName,Password, 'myurl.com'
td = teradata.UdaExec (appName="test", version="1.0", logConsole=True)
td_engine = td.connect(method="odbc",system=hostname, username=user,password=pasw,driver="Teradata") 

Perhaps change from sqlalchemy to pyodbc or other connection options.

Tyger Guzman
  • 748
  • 5
  • 13
0

Just need to include these into your script:

from sqlalchemy.dialects import registry

registry.register('presto', 'pyhive.sqlalchemy_presto', 'PrestoDialect')
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 05 '22 at 21:05