I am trying to connect to an MSSQL server from a Jupyter notebook using pyodbc and unixODBC, under macOS 10.15.4. I have just upgraded OSX to Catalina and my previously working configuration has broken.
I try to connect with:
pyodbc.connect('Driver={ODBC Driver 13 for SQL Server};Server=xxx;Database=xxx;uid=xxx;pwd=xxx;')
which throws an error:
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libmsodbcsql.13.dylib' : file not found (0) (SQLDriverConnect)")
But this file exists, and is pointed to by the driver in obdcinst.ini, and links seem correct.
To track this through, I run:
$ odbcinst -j
unixODBC 2.3.4
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /Users/johnmorgan/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
The driver file exists, and is as follows:
$ more /etc/odbcinst.ini
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/usr/local/lib/libmsodbcsql.13.dylib
UsageCount=1
The indicated Driver is a symlink - this is the 'file not found' file in the error:
$ ls -al /usr/local/lib/libmsodbcsql.13.dylib
lrwxr-xr-x 1 johnmorgan admin 54 Apr 15 08:13 /usr/local/lib/libmsodbcsql.13.dylib -> ../Cellar/msodbcsql/13.1.9.2/lib/libmsodbcsql.13.dylib
and the symlink points to the actual library file:
$ ls -al /usr/local/Cellar/msodbcsql/13.1.9.2/lib/libmsodbcsql.13.dylib
-r--r--r-- 1 johnmorgan admin 2456360 Jan 29 2018 /usr/local/Cellar/msodbcsql/13.1.9.2/lib/libmsodbcsql.13.dylib
So as far as I can tell, all the drivers, files and links are all correct.
So why do I get a 'file not found' error, and how can I fix this?
I am aware of others with this problem, eg Can't open lib 'ODBC Driver 13 for SQL Server'? Sym linking issue?, but this has not helped me resolve my issue.