Ok I've installed python3.8 on a mac, a number of odbcdrivers separately. I've created a new virtual environment and from within that environment run this:
>>> import pyodbc
>>> pyodbc.drivers()
[]
>>>
I get this no matter where I run the command.
I tried many steps, but the only thing that worked for me is the official docs on Mircosoft.
Simply follow the steps here and you are good to go. Make sure to choose the right OS (Mac / Linux) https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15
In [1]: import pyodbc
In [2]: pyodbc.drivers()
Out[2]: ['ODBC Driver 17 for SQL Server']
You have to install the following Packages to list the drivers() from pyodbc
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get -y install msodbcsql17
apt-get -y install unixodbc-dev
If you are running the MSSQL in the container run those command in the dockerfile ( If you are using Docker, based on the variant install necessary packages like curl, etc. Before running the above command )
Anything else Just Follow the Docs Here: https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With