Closed Himanshup21234 closed 6 months ago
Are you using an arm64 or amd64 Python? The issue form asks those questions for a reason, so fill it in.
@v-chojas ARM64 - I am using Apple M3 Pro.
I used this tutorial to make it work on my M1 mac, maybe it can help you.
PS: Don't forgot to change the 18s to 17, since that's the driver version you want.
Following: https://github.com/microsoft/homebrew-mssql-release/issues/53
Uninstall M1 versions of brew packages (if installed at all):
brew uninstall unixodbc msodbcsql18 mssql-tools18
Install x86 Homebrew alongside the ARM M1 homebrew:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Then use x86 homebrew like arch -x86_64 /usr/local/bin/brew install or use the following alias (add to ~/.bash_profile or ~/.zshrc):
# Relies on having installed x86 brew like:
# arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
alias x86brew="arch -x86_64 /usr/local/bin/brew"
alias brew="/opt/homebrew/bin/brew" # M1 version, to avoid from using x86 version accidentally
Install the ODBC packages.
x86brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
x86brew update
HOMEBREW_ACCEPT_EULA=Y x86brew install msodbcsql18 mssql-tools18
Create an x86 conda env with:
ENV_NAME="rosetta"
CONDA_SUBDIR=osx-64 conda create -n $ENV_NAME python
conda activate $ENV_NAME
conda config --env --set subdir osx-64
In order to install pyodbc, add to path (add to ~/.bash_profile or ~/.zshrc):
export LDFLAGS="-L/usr/local/Cellar/unixodbc/2.3.12/lib"
export CPPFLAGS="-I/usr/local/Cellar/unixodbc/2.3.12/include"
export PKG_CONFIG_PATH="/usr/local/Cellar/unixodbc/2.3.12/lib/pkgconfig"
PS: Pyodbc needs to be a recent version to be used with MAC M1.
That will work if you need to run x86 Python on an arm64 Mac for some reason, but beware that if you have other Python packages that are arm64, your x86 Python won't work with them.
Environment
To diagnose, we usually need to know the following, including version numbers. On Windows, be sure to specify 32-bit Python or 64-bit:
Issue
I have Mac M3 Pro, trying to connect to Azure SQL server using pyodbc. my settings works well on my previous mac intel chip base laptop, but not here. This is the error I get when trying to connect to sql server using pyodbc
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/opt/homebrew/lib/libmsodbcsql.17.dylib' : file not found (0) (SQLDriverConnect)")
I checked lipo -info /opt/homebrew/Cellar/msodbcsql18/18.1.1.1/lib/libmsodbcsql.18.dylib