【发布时间】:2022-07-12 16:27:24
【问题描述】:
我正在尝试在 macOS(12.3.1) 上使用 pip 安装 pyodbc,但这不起作用。
在错误日志中,消息说“致命错误:找不到'sql.h'文件”。命令brew install unixodbc 帮助了一些人。我确实运行了brew install unixodbc,但仍然出现错误。
我的环境: MacBook Pro M1 点(22.0.4) 蟒蛇 (3.10) pyenv (2.2.5)
对不起,英语不好,对python的理解很差。
% pip3 install pyodbc
Collecting pyodbc
Using cached pyodbc-4.0.32.tar.gz (280 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: pyodbc
Building wheel for pyodbc (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [14 lines of output]
running bdist_wheel
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.macosx-12.1-arm64-3.10
creating build/temp.macosx-12.1-arm64-3.10/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -DPYODBC_VERSION=4.0.32 -UMAC_OS_X_VERSION_10_7 -I/usr/local/include -I/Users/daiki/.pyenv/versions/3.10.0/include/python3.10 -c src/buffer.cpp -o build/temp.macosx-12.1-arm64-3.10/src/buffer.o -Wno-write-strings -Wno-deprecated-declarations
In file included from src/buffer.cpp:12:
src/pyodbc.h:56:10: fatal error: 'sql.h' file not found
#include <sql.h>
^~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyodbc
Running setup.py clean for pyodbc
Failed to build pyodbc
Installing collected packages: pyodbc
Running setup.py install for pyodbc ... error
error: subprocess-exited-with-error
× Running setup.py install for pyodbc did not run successfully.
│ exit code: 1
╰─> [14 lines of output]
running install
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.macosx-12.1-arm64-3.10
creating build/temp.macosx-12.1-arm64-3.10/src
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -DPYODBC_VERSION=4.0.32 -UMAC_OS_X_VERSION_10_7 -I/usr/local/include -I/Users/daiki/.pyenv/versions/3.10.0/include/python3.10 -c src/buffer.cpp -o build/temp.macosx-12.1-arm64-3.10/src/buffer.o -Wno-write-strings -Wno-deprecated-declarations
In file included from src/buffer.cpp:12:
src/pyodbc.h:56:10: fatal error: 'sql.h' file not found
#include <sql.h>
^~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> pyodbc
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
【问题讨论】: