Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to load sqlalchemy-plugin in pyinstaller'ed exe #3518

Closed
binilg opened this issue May 16, 2018 · 4 comments · Fixed by #8465
Closed

Failing to load sqlalchemy-plugin in pyinstaller'ed exe #3518

binilg opened this issue May 16, 2018 · 4 comments · Fixed by #8465

Comments

@binilg
Copy link

binilg commented May 16, 2018

This line of code works perfectly fine while running as a file from spyder.

engine = sqlalchemy.create_engine('teradata://uid:pwd@DBinstance?driver=Teradata')
However, after making an exe file using pyinstaller, I get the following error while running the exe:

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

This looks to be an exe-creation-issue in loading libraries. Has anyone encountered a similar issue and was able to resolve? Any pointers would be appreciated.

@nullne
Copy link

nullne commented Nov 19, 2018

similar problem, any help?

@Coder0951
Copy link

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") 

@bchoudhary6415
Copy link

bchoudhary6415 commented May 13, 2024

Similar problem I'm getting can anyone help me?
Please refer this issue - ibmdb/python-ibmdbsa#143
The error I'm getting is below

`[19460] PyInstaller Bootloader 6.x
[19460] LOADER: executable is C:\Users\bchoudhary\ibmdb12.1\app\dist\sqlalchemySample\sqlalchemySample.exe
[19460] LOADER: _MEIPASS2 is not set
[19460] LOADER: archivename is C:\Users\bchoudhary\ibmdb12.1\app\dist\sqlalchemySample\sqlalchemySample.exe
[19460] LOADER: Cookie found at offset 0x50803F
[19460] LOADER: No need to extract files to run; setting extractionpath to homepath
[19460] LOADER: SetDllDirectory(C:\Users\bchoudhary\ibmdb12.1\app\dist\sqlalchemySample\_internal)
[19460] LOADER: Already in the child - running user's code.
[19460] LOADER: Python library: C:\Users\bchoudhary\ibmdb12.1\app\dist\sqlalchemySample\_internal\python312.dll
[19460] LOADER: Loaded functions from Python library.
[19460] LOADER: Pre-initializing embedded python interpreter...
[19460] LOADER: Creating PyConfig structure...
[19460] LOADER: Initializing interpreter configuration...
[19460] LOADER: Setting program name...
[19460] LOADER: Setting python home path...
[19460] LOADER: Setting module search paths...
[19460] LOADER: Setting sys.argv...
[19460] LOADER: Applying run-time options...
[19460] LOADER: Starting embedded python interpreter...
[19460] LOADER: setting sys._MEIPASS
[19460] LOADER: importing modules from CArchive
[19460] LOADER: extracted struct
[19460] LOADER: running unmarshalled code object for struct...
[19460] LOADER: extracted pyimod01_archive
[19460] LOADER: running unmarshalled code object for pyimod01_archive...
[19460] LOADER: extracted pyimod02_importers
[19460] LOADER: running unmarshalled code object for pyimod02_importers...
[19460] LOADER: extracted pyimod03_ctypes
[19460] LOADER: running unmarshalled code object for pyimod03_ctypes...
[19460] LOADER: extracted pyimod04_pywin32
[19460] LOADER: running unmarshalled code object for pyimod04_pywin32...
[19460] LOADER: Installing PYZ archive with Python modules.
[19460] LOADER: PYZ archive: PYZ-00.pyz
[19460] LOADER: Running pyiboot01_bootstrap.py
[19460] LOADER: Running pyi_rth_inspect.py
[19460] LOADER: Running pyi_rth_pkgutil.py
[19460] LOADER: Running pyi_rth_multiprocessing.py
[19460] LOADER: Running sqlalchemySample.py
Traceback (most recent call last):
  File "sqlalchemySample.py", line 14, in <module>
  File "<string>", line 2, in create_engine
  File "sqlalchemy\util\deprecations.py", line 281, in warned
  File "sqlalchemy\engine\create.py", line 552, in create_engine
  File "sqlalchemy\engine\url.py", line 755, in _get_entrypoint
  File "sqlalchemy\util\langhelpers.py", line 374, in load
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:ibm_db_sa
[19460] Failed to execute script 'sqlalchemySample' due to unhandled exception!
[19460] LOADER: ERROR.
[19460] LOADER: Manually flushing stdout and stderr
[19460] LOADER: Cleaning up Python interpreter.`

@rokm
Copy link
Member

rokm commented May 13, 2024

The sqlalchemy plugins are discovered via entry-points, so you need to collect metadata and add the module to hiddenimports.

In the case of ibm_db_sa, add --copy-metadata ibm-db-sa --hiddenimport ibm_db_sa to your PyInstaller command.

If you get missing-module errors for modules from ibm_db_sa, replace --hiddenimport ibm_db_sa with --collect-submodules ibm_db_sa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants