pyodbc: driver not found, Pyodbc.drivers=[]: pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
Environment
- Python: 3.9.7
- pyodbc: 4.0.32
- OS: MacOS 12.0.1, Apple M1 Max
- DB: Azure SQL
- driver: ODBC Driver 17 for SQL Server
Issue
When running
import pyodbc
server = 'xxx.database.windows.net'
database = 'yyy'
username = 'zzz'
password = '???
odbc_driver = '{ODBC Driver 17 for SQL Server}'
conn_str = f'DRIVER={odbc_driver};SERVER=tcp:{server};PORT=1433;DATABASE={database};UID={username};PWD={password}'
print('opening....')
cnn = pyodbc.connect(conn_str)
print("opened")
I get
File "/Users/deniz/OneDrive/Dev/webhook_receiver/sql.py", line 12, in <module>
cnn = pyodbc.connect(conn_str)
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
output:
opening....
[ODBC][95553][1650740040.206997][__handles.c][460]
Exit:[SQL_SUCCESS]
Environment = 0x7fb930024c00
[ODBC][95553][1650740040.207022][SQLSetEnvAttr.c][189]
Entry:
Environment = 0x7fb930024c00
Attribute = SQL_ATTR_ODBC_VERSION
Value = 0x3
StrLen = 4
[ODBC][95553][1650740040.207060][SQLSetEnvAttr.c][381]
Exit:[SQL_SUCCESS]
[ODBC][95553][1650740040.207073][SQLAllocHandle.c][377]
Entry:
Handle Type = 2
Input Handle = 0x7fb930024c00
UNICODE Using encoding ASCII 'UTF-8' and UNICODE 'UCS-2-INTERNAL'
[ODBC][95553][1650740040.207119][SQLAllocHandle.c][513]
Exit:[SQL_SUCCESS]
Output Handle = 0x7fb930029600
[ODBC][95553][1650740040.207368][SQLDriverConnectW.c][290]
Entry:
Connection = 0x7fb930029600
Window Hdl = 0x0
Str In = [DRIVER={ODBC Driver 17 for SQL Server};SERVER=tcp:xxx.database.windows.net;PORT=1433;DATABASE=yyy...][length = 166 (SQL_NTS)]
Str Out = 0x0
Str Out Max = 0
Str Out Ptr = 0x0
Completion = 0
[ODBC][95553][1650740040.209211][SQLConnect.c][1140]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found
[ODBC][95553][1650740040.209244][SQLDriverConnect.c][748]
Entry:
Connection = 0x7fb930029600
Window Hdl = 0x0
Str In = [DRIVER={ODBC Driver 17 for SQL Server};SERVER=tcp:xxx;PORT=1433;DATABASE=yyy...][length = 166 (SQL_NTS)]
Str Out = 0x3076d55c0
Str Out Max = 2048
Str Out Ptr = 0x0
Completion = 0
[ODBC][95553][1650740040.209362][SQLConnect.c][1140]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found
[ODBC][95553][1650740040.209384][SQLGetDiagRecW.c][535]
Entry:
Connection = 0x7fb930029600
Rec Number = 1
SQLState = 0x3076d7964
Native = 0x3076d794c
Message Text = 0x7fb93003a600
Buffer Length = 1023
Text Len Ptr = 0x3076d7962
[ODBC][95553][1650740040.209410][SQLGetDiagRecW.c][596]
Exit:[SQL_SUCCESS]
SQLState = [01000]
Native = 0x3076d794c -> 0 (32 bits)
Message Text = [[unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found]
[ODBC][95553][1650740040.209439][SQLFreeHandle.c][290]
Entry:
Handle Type = 2
Input Handle = 0x7fb930029600
[ODBC][95553][1650740040.209451][SQLFreeHandle.c][339]
Exit:[SQL_SUCCESS]
How can I fix this?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 16 (5 by maintainers)
python --version