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

3

7

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**
Cuellar answered 13/12, 2021 at 11:28 Comment(0)
C
18

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/[email protected]/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.

Cuellar answered 13/12, 2021 at 11:34 Comment(2)
Thank you. This is only one that worked for meAsepsis
Glad it worked for you 💯Cuellar
I
15

Running the following commands fixed my issue

$ brew install freetds openssl
$ echo 'export LDFLAGS="-L/opt/homebrew/opt/freetds/lib -L/opt/homebrew/opt/openssl@3/lib"' >> ~/.zshrc
$ echo 'export CFLAGS="-I/opt/homebrew/opt/freetds/include"' >> ~/.zshrc
$ echo 'export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"' >> ~/.zshrc
$ source ~/.zshrc
$ pip3 install pymssql
Indevout answered 4/1, 2022 at 19:24 Comment(0)
S
0

If it is the case that anyone is using M1 macos, it may be the case that your current Brew installation is on your user's folder instead of the recommended prefix (/opt/homebrew), I reccommend to uninstall brew and install it again to avoid these problems (or change the prefix as the Brew installation recommends after the installation).

After installing Brew it should show you this:

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your   PATH:
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/your_user/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
https://docs.brew.sh

After running the recommended command you can validate with:

brew --prefix

And if all worked fine it should output:

/opt/homebrew
Sterculiaceous answered 26/6, 2024 at 21:2 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.