Search code examples
python-3.xpyinstaller

Failed to load dynlib/dll


I am trying to package the following Python code into an executable file using PyInstaller:

import pandas as pd
import teradatasql  

with teradatasql.connect(host='abcdxxx', user='abcdxxx', password='abcdxxx') as connect:
        query = "SHOW TABLE AdventureWorksDW.DimAccount"
        df = pd.read_sql(query, connect)
        print(df)

When I run the .exe file, it gives me the error:

PyInstallerImportError: Failed to load dynlib/dll 
'C:\\Users\\GAX~1.P\\AppData\\Local\\Temp\\_MEI153202\\teradatasql\\teradatasql.dll'. 
Most likely this dynlib/dll was not found when the application was frozen.
[9924] Failed to execute script 'hello' due to unhandled exception!

I tried to make the following changes to the .spec file:

b = [
    ('C:\Users\Path_to_Python\Python\Python310\Lib\site-
      packages\teradatasql\teradatasql.dll', '.\\teradatasql')
     ]

a = Analysis(['hello.py'],
             pathex=[],
             binaries=b,
             datas=[] # , .....
             )

But it doesn't resolve the problem. How to fix this?


Solution

  • We provide an article explaining how to include the Teradata SQL Driver for Python into an application packaged by PyInstaller: https://support.teradata.com/community?id=community_blog&sys_id=c327eac51b1e9c103b00bbb1cd4bcb37