错误:无法构建pymssql的轮子,这是安装基于pyproject.toml项目所需的。在Mac M1上。

3
我正在使用搭载M1芯片的MacBook,似乎有多个东西没有为其进行优化。
pyodbc对我来说无法使用,所以我想使用pymssql
然而,当我尝试运行pip install pymssql时,遇到了以下错误。
  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**
2个回答

14

在尝试了很多解决方案之后,似乎有些方法对我有效。下面提供的代码可用于解决此问题。

重要提示: 根据您的系统更改路径。

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

只需运行上述命令,问题便可得到解决,因为它对我起作用了。


谢谢。这是唯一对我有效的。 - Xathras
很高兴它对你起作用了。 - Lakshay Rohilla

10
以下命令解决了我的问题。
$ 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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接