mkleehammer / pyodbc

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

Failed to build pyodbc. Cannot install on M1 MAC Monterey #988

Closed MiguelElGallo closed 7 months ago

MiguelElGallo commented 2 years ago

Please first make sure you have looked at:

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:

Issue

When installing PyODBC it fails with: 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

In file included from src/buffer.cpp:12: src/pyodbc.h:56:10: fatal error: 'sql.h' file not found

include

       ^~~~~~~

1 error generated. error: command 'clang' failed with exit status 1

ERROR: Failed building wheel for pyodbc

v-chojas commented 2 years ago

Please install unixODBC first ,as pointed out in the documentation.

MiguelElGallo commented 2 years ago

Is installed and working: unixodbc 2.3.9_1 , error still persists

v-makouz commented 2 years ago

Is the file sql.h in /usr/local/include/ or /usr/local/Cellar/unixodbc/2.3.9/include/ (if it was installed via brew)? I believe that's where it should be placed after installing unixODBC. If the files are there then there is something wrong with installation not looking in the right paths.

askpatrickw commented 2 years ago

Installing unixodbc and Setting LDFLAGS and CPPFLAGS as mentioned on the main issue (https://github.com/mkleehammer/pyodbc/issues/846#issuecomment-986649632) for this worked for me.
My path was slightly different. Check yours.

ll /opt/homebrew/Cellar/unixodbc

PSalant726 commented 2 years ago

@MiguelElGallo See https://github.com/mkleehammer/pyodbc/issues/846#issuecomment-813255685 for a workaround.

The default Homebrew installation path has changed for M1 Macs: /usr/local/ --> /opt/homebrew/.

Bturan19 commented 2 years ago

Is the file sql.h in /usr/local/include/ or /usr/local/Cellar/unixodbc/2.3.9/include/ (if it was installed via brew)? I believe that's where it should be placed after installing unixODBC. If the files are there then there is something wrong with installation not looking in the right paths.

This was the problem for me, after applying those two steps problem solved..

Lilya-CB commented 2 years ago

After looking around this is the solution that worked for me:

Step 1 - Install unixodbc with brew brew install unixodbc

Step 2 - Make sure to note the version that has just been installed (as of today, I installed unixodbc 2.3.11)

Step 3 - Create the links just like in the documentation that you provided https://github.com/mkleehammer/pyodbc/wiki export LDFLAGS="-L/opt/homebrew/Cellar/unixodbc/[your version]/lib" export CPPFLAGS="-I/opt/homebrew/Cellar/unixodbc/[your version]/include"

Step 4 - Go on your project to install pyodbc pip install pyobdc

And watch it FINALLY work!!

mkleehammer commented 1 year ago

Earlier releases did not include Apple Silicon / ARM binary wheels, but we've added them to 5.0.0 beta 2. If you can, please test them. Details here:

https://github.com/mkleehammer/pyodbc/discussions/1263

ramyaelineni5 commented 9 months ago

Below command worked for to get wheel python -m pip install --only-binary=:all: pyodbc==4.0.32

But how to install ODBC driver in AWS Glue to connect AWS Microsoft RDS ?

keitherskine commented 7 months ago

Fixed by #1323 .