macospipapple-m1pymssql

ERROR: Could not build wheels for pymssql, which is required to install pyproject.toml-based projects In Mac M1


I`m using MacBook with M1 chip and seems like multiple things arent optimised for it.
pyodbc didnt work for me, so I wanted to use pymssql.
Though, I encountered this issue when I tried to run pip install pymssql.

The error is as below.

  Using cached pymssql-2.2.2.tar.gz (170 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pymssql
  Building wheel for pymssql (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
Your project path and someinfo about it.

Complete output (25 lines):
  setup.py: platform.system() => Darwin
  setup.py: platform.architecture() => ('64bit', '')
  setup.py: platform.libc_ver() => ('', '')
  setup.py: include_dirs => []
  setup.py: library_dirs => []
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-universal2-3.9
  creating build/lib.macosx-10.9-universal2-3.9/pymssql
  copying src/pymssql/__init__.py -> build/lib.macosx-10.9-universal2-3.9/pymssql
  running build_ext
  cythoning src/pymssql/_mssql.pyx to src/pymssql/_mssql.c
  cythoning src/pymssql/_pymssql.pyx to src/pymssql/_pymssql.c
  building 'pymssql._mssql' extension
  creating build/temp.macosx-10.9-universal2-3.9
  creating build/temp.macosx-10.9-universal2-3.9/src
  creating build/temp.macosx-10.9-universal2-3.9/src/pymssql
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Users/lakshayrohilla/SMS Project Files /cracs-backend/.venv/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pymssql/_mssql.c -o build/temp.macosx-10.9-universal2-3.9/src/pymssql/_mssql.o -DMSDBLIB
  src/pymssql/_mssql.c:682:10: fatal error: 'sqlfront.h' file not found
  #include "sqlfront.h"
           ^~~~~~~~~~~~
  1 error generated.
  error: command '/usr/bin/gcc' failed with exit code 1
  ----------------------------------------
  **ERROR: Failed building wheel for pymssql**
Failed to build pymssql
**ERROR: Could not build wheels for pymssql, which is required to install pyproject.toml-based projects**

Solution

  • On trying loads of solutions for fixing this issue, Seems like something worked out for me.
    I`m providing the code below for solving this issue.

    Important Note: Change the path as per your system.

    1. brew install freetds
    2. brew install openssl
    3. export LDFLAGS="-L/opt/homebrew/Cellar/freetds/1.3.3/lib -L/opt/homebrew/Cellar/openssl@1.1/1.1.1l_1/lib"
    4. export CFLAGS="-I/opt/homebrew/Cellar/freetds/1.3.3/include" 
    5. pip install pymssql
    

    Just run the above commands & it should solve your issue, as it worked out for me.