How to install pymssql on MacOS Sierra
As of Feb 2021
I can no longer install [email protected] as homebrew does not have it available. The current version of freetds is 1.2.18 and brew link --force freetds
doesn't seem to change anything.
The root issue 'sqlfront.h' file not found
is due to the freetds files not linking properly during installation. We can fix this by doing
export LDFLAGS="-L/opt/homebrew/opt/freetds/lib"
export CPPFLAGS="-I/opt/homebrew/opt/freetds/include"
pip install pymssql
Where /opt/homebrew/opt/freetds
is where homebrew installed freetds on your system (I am on Apple Silicon) and may be different for you. If you are on Intel your's might look something like /usr/local/opt/freetds
.
To find exactly where homebrew installed freetds (or any program for that matter) on your system, you can do
brew --prefix freetds
This should return something like /opt/homebrew/opt/freetds
or /opt/homebrew/opt/[email protected]
. You can ignore any version numbers and append /lib
and /include
to get the paths you need.
This is a handy trick to keep in mind as it is applicable to lots of other install issues with dependencies installed via homebrew.
This link ended up solving my problem. For anyone else having these issues, this sequence of commands worked for me.
brew uninstall --force freetds
brew install [email protected]
brew link --force [email protected]
pip install pymssql