Pyodbc.drivers() returning an empty list on Mac

Viewed 2610

I'm attempting to access an SQL Database using sqlalchemy, but I seemingly don't have any ODBC drivers installed. I've followed Microsoft's instructions on installing ODBC drivers via Homebrew here:

https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-2017

But still am turning up short. When I perform pip install pyodbc, it returns that it's installed. However, when I search for the drivers, I just get an empty list:

In[1]: import pyodbc
In[2]: pyodbc.drivers()
Out[2]: []

Thanks in advance.

1 Answers

Some users encounter an issue when trying to connect after installing the ODBC driver and receive an error like: "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)". It may be the case that unixODBC is not configured correctly to find registered drivers. In these cases, creating a couple symbolic links can resolve the issue.

sudo ln -s /usr/local/etc/odbcinst.ini /etc/odbcinst.ini
sudo ln -s /usr/local/etc/odbc.ini /etc/odbc.ini

The above works for me. ref

Related