mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.92k stars 563 forks source link

I can't install pyodbc on python 3.10 under macOS #995

Closed ensofter closed 2 years ago

ensofter commented 2 years ago

I'm trying install pyodbc on python 3.10 macos m1 chip and get error

ERROR: Failed building wheel for pyodbc

then pip trying install by setup.py and again get error

DEPRECATION: Could not build wheels for pyodbc which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.

ERROR: Command errored out with exit status 1:
 command: /Users/p3.101/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/vl/ptr9mwg51yq8jzwyp7z6_kr00000gp/T/pip-install-3fjgpudw/pyodbc/setup.py'"'"'; __file__='"'"'/private/var/folders/vl/ptr9mwg51yq8jzwyp7z6_kr00000gp/T/pip-install-3fjgpudw/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/vl/ptr9mwg51yq8jzwyp7z6_kr00000gp/T/pip-record-jrpj2h0_/install-record.txt --single-version-externally-managed --compile --install-headers /Users/p3.101/include/site/python3.10/pyodbc
     cwd: /private/var/folders/vl/ptr9mwg51yq8jzwyp7z6_kr00000gp/T/pip-install-3fjgpudw/pyodbc/
Complete output (16 lines):
running install
/Users/p3.101/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.macosx-11.6-arm64-3.10
creating build/temp.macosx-11.6-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/Users/p3.101/include -I/.pyenv/versions/3.10.1/include/python3.10 -c src/buffer.cpp -o build/temp.macosx-11.6-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

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be sure to specify 32-bit Python or 64-bit:

Maybe you know how i can fix this problem?

gordthompson commented 2 years ago

Have you seen this?

ensofter commented 2 years ago

No, bu thx. I will try

KadenWolff commented 2 years ago

I'm currently getting this error under the exact same conditions. MacOS, m1 chip, Python 3.10, latest version of pyodbc. I've installed unixodbc with brew, but that has not resolved the issue. Should I open a new issue?

v-chojas commented 2 years ago

Check that you are not mixing x86 and arm versions. There's been a few recent issues here about that.

KadenWolff commented 2 years ago

How do I check that in this case?

kbernou commented 2 years ago

For posterity, and in case you haven't found a solution, I found this elsewhere and it resolved the problem for me (assuming pyodbc and unixodbc were already uninstalled):

brew install unixodbc
export LDFLAGS="-L/opt/homebrew/Cellar/unixodbc/2.3.9_1/lib"
export CPPFLAGS="-I/opt/homebrew/Cellar/unixodbc/2.3.9_1/include"
pip3 install pyodbc