pyodbc icon indicating copy to clipboard operation
pyodbc copied to clipboard

Need Apple Silicon / M1 builds

Open zibbou opened this issue 5 years ago • 48 comments

Installation fails on Mac OS 11.0

It seems the binary have not been released yet.

Manual installation fails as well from whl file :

ERROR: pyodbc-4.0.30-cp39-cp39-macosx_10_9_x86_64.whl is not a supported wheel on this platform.

Do you know any workaround?

zibbou avatar Nov 19 '20 07:11 zibbou

I was able to run it under Mac OS 11.0 on a MacBook Air with the new M1 chip. You need to download the source by yourself and run python setup.py build followed by python setup.py install.

tovolkmar avatar Nov 20 '20 17:11 tovolkmar

That said, the ARM Mac ODBC drivers which you will need are probably still rather uncommon for the time being, given that Apple just released the new M1 Macs recently.

v-chojas avatar Nov 20 '20 21:11 v-chojas

I'm able to install, but running connect fails:

InterfaceError: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found and no default driver specified (0) (SQLDriverConnect)')

If I look at drivers(), it also returns an empty list. However, I am able to connect using isql with the data source name as an argument, so it does not appear to be an issue with FreeTDS or unixODBC.

The main departure from the install instructions for me is that I used MacPorts (Homebrew does not work for M1 yet). I wonder if that has anything to do with it (i.e. files being located in /opt). The setup.py script seems to account for this though.

fonnesbeck avatar Dec 02 '20 17:12 fonnesbeck

You can see which unixODBC the pyODBC has linked to, run otool -L on the pyODBC library you get with

import pyodbc.
pyodbc.__file__

v-chojas avatar Dec 02 '20 20:12 v-chojas

I'm getting:

otool -L /Users/cfonnesbeck/anaconda3/lib/python3.8/site-packages/pyodbc.cpython-38-darwin.so

/Users/cfonnesbeck/anaconda3/lib/python3.8/site-packages/pyodbc.cpython-38-darwin.so:
	@rpath/libodbc.2.dylib (compatibility version 3.0.0, current version 3.0.0)
	@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.0.0)

fonnesbeck avatar Dec 02 '20 22:12 fonnesbeck

That indicates it will be loaded from whatever happens to be in the rpath when the Python is running, and since that depends on what other libraries it has, it is probably easier to run find / -name libodbc.2.dylib to show all the occurrences of unixODBC libraries you have; I suspect there is more than one.

v-chojas avatar Dec 02 '20 22:12 v-chojas

I'm going to rename this to emphasize the issue is Apple Silicon / M1 compatibility. I have access to an M1 Air (though I'm not sure the wife is going to like that :) ) but I've been waiting because of the Homebrew issue. I'm interested in any feedback people have and suggestions on which DBs can be run natively on the M1 for testing.

mkleehammer avatar Jan 22 '21 03:01 mkleehammer

Just FYI @mkleehammer brew is already working for Apple Silicon, with just a slight change on the PATH.

Bearzooka avatar Feb 04 '21 13:02 Bearzooka

I was able to run it under Mac OS 11.0 on a MacBook Air with the new M1 chip. You need to download the source by yourself and run python setup.py build followed by python setup.py install.

Hi, I am having a fatal error: 'sql.h' file not found error. sql.h doesn't look to be part of the package. pyodbc installs just fine, with brew.

marcozanella avatar Feb 09 '21 15:02 marcozanella

You need to install unixODBC. Please, read the documentation: https://github.com/mkleehammer/pyodbc/wiki/Building-pyodbc-from-source

v-chojas avatar Feb 09 '21 15:02 v-chojas

You need to install unixODBC. Please, read the documentation: https://github.com/mkleehammer/pyodbc/wiki/Building-pyodbc-from-source

I don't see any documentation from your link that talks about the installation of unixODBC specific for Apple Silicon/M1 , can you provide exact steps if you were successful?

msarm avatar Feb 14 '21 19:02 msarm

Hi, I have installed unixodbc via brew; and installed correctly. However, when installing pyodbc, I get the following error message, followed by more information, with mention sql.h is not found

Collecting pyodbc

Using cached pyodbc-4.0.30.tar.gz (266 kB)

Building wheels for collected packages: pyodbc

Building wheel for pyodbc (setup.py) ... error

ERROR: Command errored out with exit status 1:

command: /Users/marcozanella/.pyenv/versions/3.9.1/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/dk/kq7_26dj5z79542rb3jp0c340000gn/T/pip-install-05exfppr/pyodbc_64a047783b5647e98f08d3659e1cd34b/setup.py'"'"'; file='"'"'/private/var/folders/dk/kq7_26dj5z79542rb3jp0c340000gn/T/pip-install-05exfppr/pyodbc_64a047783b5647e98f08d3659e1cd34b/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/dk/kq7_26dj5z79542rb3jp0c340000gn/T/pip-wheel-de40jc02

   cwd:

/private/var/folders/dk/kq7_26dj5z79542rb3jp0c340000gn/T/pip-install-05exfppr/pyodbc_64a047783b5647e98f08d3659e1cd34b/

Complete output (14 lines):

running bdist_wheel

running build

running build_ext

building 'pyodbc' extension

creating build

creating build/temp.macosx-11.2-arm64-3.9

creating build/temp.macosx-11.2-arm64-3.9/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.30 -UMAC_OS_X_VERSION_10_7 -I/Users/marcozanella/.pyenv/versions/3.9.1/include/python3.9 -c src/buffer.cpp -o build/temp.macosx-11.2-arm64-3.9/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


ERROR: Failed building wheel for pyodbc

I will check if I could build from source, according to your suggestions.

Thanks Marco

On Tue, Feb 9, 2021 at 4:35 PM v-chojas [email protected] wrote:

You need to install unixODBC. Please, read the documentation: https://github.com/mkleehammer/pyodbc/wiki/Building-pyodbc-from-source

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mkleehammer/pyodbc/issues/846#issuecomment-776028408, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKGK47UZYN4EDDTBB5ENJ3S6FI4LANCNFSM4T3ALN3A .

-- Marco Zanella [email protected]

marcozanella avatar Feb 15 '21 16:02 marcozanella

https://github.com/mkleehammer/pyodbc/pull/872 https://github.com/mkleehammer/pyodbc/pull/870

v-chojas avatar Feb 16 '21 15:02 v-chojas

Hi, I have installed unixodbc via brew; and installed correctly. However, when installing pyodbc, I get the following error message, followed by more information, with mention sql.h is not found Collecting pyodbc Using cached pyodbc-4.0.30.tar.gz (266 kB) Building wheels for collected packages: pyodbc Building wheel for pyodbc (setup.py) ... error ERROR: Command errored out with exit status 1: command: /Users/marcozanella/.pyenv/versions/3.9.1/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/dk/kq7_26dj5z79542rb3jp0c340000gn/T/pip-install-05exfppr/pyodbc_64a047783b5647e98f08d3659e1cd34b/setup.py'"'"'; file='"'"'/private/var/folders/dk/kq7_26dj5z79542rb3jp0c340000gn/T/pip-install-05exfppr/pyodbc_64a047783b5647e98f08d3659e1cd34b/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/dk/kq7_26dj5z79542rb3jp0c340000gn/T/pip-wheel-de40jc02 cwd: /private/var/folders/dk/kq7_26dj5z79542rb3jp0c340000gn/T/pip-install-05exfppr/pyodbc_64a047783b5647e98f08d3659e1cd34b/ Complete output (14 lines): running bdist_wheel running build running build_ext building 'pyodbc' extension creating build creating build/temp.macosx-11.2-arm64-3.9 creating build/temp.macosx-11.2-arm64-3.9/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.30 -UMAC_OS_X_VERSION_10_7 -I/Users/marcozanella/.pyenv/versions/3.9.1/include/python3.9 -c src/buffer.cpp -o build/temp.macosx-11.2-arm64-3.9/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

I managed to solve the src/pyodbc.h:56:10: fatal error: 'sql.h' file not found issue on my M1 (Apple Silicion) MacBook Pro by running:

  1. brew install unixodbc
  2. export LDFLAGS="-L/opt/homebrew/Cellar/unixodbc/2.3.9/lib"
  3. export CPPFLAGS="-I/opt/homebrew/Cellar/unixodbc/2.3.9/include"

Hope it helps.

michalpulpan avatar Apr 05 '21 07:04 michalpulpan

Thanks @michalpulpan. I can confirm that the following works on my MacBook M1:

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

pip is here an aliased to /opt/homebrew/bin/pip3

jontingvold avatar Apr 08 '21 20:04 jontingvold

Thanks @michalpulpan. I can confirm that the following works on my MacBook M1:

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

pip is here an aliased to /opt/homebrew/bin/pip3

I did install the unixODBC using Homebrew. And I have the Python installed using the Graphic Installer, instead of Homebrew installation of Python.

I don't know if it is creating the problem, but installing the unixodbc is still throwing the same error after importing pyodbc

I did also tried using brew install python3, but Homebrew version of python do not install the other libraries like Pandas, Numpy, Pyodbc too. So I installed the Python3 graphically and got all the other libraries installed.

I have MacBook Air M1

Do I have to install the Homebrew version of python3?

Ritish-Madan avatar May 07 '21 10:05 Ritish-Madan

Hello,

same and weird issue. Installation in my M1 Mac Mini was working fine. Now attempting to install pyodbc on M1 Macbook Air results in error

philipp@Air-von-Philipp bin % brew install unixodbc
Warning: unixodbc 2.3.9_1 is already installed and up-to-date.
To reinstall 2.3.9_1, run:
  brew reinstall unixodbc
philipp@Air-von-Philipp bin % export LDFLAGS="-L/opt/homebrew/Cellar/unixodbc/2.3.9/lib"
philipp@Air-von-Philipp bin % export CPPFLAGS="-I/opt/homebrew/Cellar/unixodbc/2.3.9/include"
philipp@Air-von-Philipp bin % ./python3 -m pip install pyodbc                                
Collecting pyodbc
  Using cached pyodbc-4.0.30.tar.gz (266 kB)
Building wheels for collected packages: pyodbc
  Building wheel for pyodbc (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/homebrew/opt/[email protected]/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"'; __file__='"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-wheel-jvs3kf9i
       cwd: /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/
  Complete output (27 lines):
  /opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py:669: UserWarning: Usage of dash-separated 'library-dirs' will not be supported in future versions. Please use the underscore name 'library_dirs' instead
    warnings.warn(
  running bdist_wheel
  running build
  running build_ext
  building 'pyodbc' extension
  creating build
  creating build/temp.macosx-11-arm64-3.9
  creating build/temp.macosx-11-arm64-3.9/src
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/buffer.cpp -o build/temp.macosx-11-arm64-3.9/src/buffer.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/cnxninfo.cpp -o build/temp.macosx-11-arm64-3.9/src/cnxninfo.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/connection.cpp -o build/temp.macosx-11-arm64-3.9/src/connection.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/cursor.cpp -o build/temp.macosx-11-arm64-3.9/src/cursor.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/errors.cpp -o build/temp.macosx-11-arm64-3.9/src/errors.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/getdata.cpp -o build/temp.macosx-11-arm64-3.9/src/getdata.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/params.cpp -o build/temp.macosx-11-arm64-3.9/src/params.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbccompat.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbccompat.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbcdbg.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbcdbg.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbcmodule.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbcmodule.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/row.cpp -o build/temp.macosx-11-arm64-3.9/src/row.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/textenc.cpp -o build/temp.macosx-11-arm64-3.9/src/textenc.o -Wno-write-strings -Wno-deprecated-declarations
  creating build/lib.macosx-11-arm64-3.9
  clang++ -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/opt/homebrew/Cellar/unixodbc/2.3.9/lib -I/opt/homebrew/Cellar/unixodbc/2.3.9/include build/temp.macosx-11-arm64-3.9/src/buffer.o build/temp.macosx-11-arm64-3.9/src/cnxninfo.o build/temp.macosx-11-arm64-3.9/src/connection.o build/temp.macosx-11-arm64-3.9/src/cursor.o build/temp.macosx-11-arm64-3.9/src/errors.o build/temp.macosx-11-arm64-3.9/src/getdata.o build/temp.macosx-11-arm64-3.9/src/params.o build/temp.macosx-11-arm64-3.9/src/pyodbccompat.o build/temp.macosx-11-arm64-3.9/src/pyodbcdbg.o build/temp.macosx-11-arm64-3.9/src/pyodbcmodule.o build/temp.macosx-11-arm64-3.9/src/row.o build/temp.macosx-11-arm64-3.9/src/textenc.o -L/usr/local/lib -L/usr/lib -L/usr/local/lib -lodbc -o build/lib.macosx-11-arm64-3.9/pyodbc.cpython-39-darwin.so
  ld: warning: directory not found for option '-L/opt/homebrew/Cellar/unixodbc/2.3.9/lib'
  ld: library not found for -lodbc
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command '/usr/bin/clang++' failed with exit code 1
  ----------------------------------------
  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: Command errored out with exit status 1:
     command: /opt/homebrew/opt/[email protected]/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"'; __file__='"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-record-axaz51v3/install-record.txt --single-version-externally-managed --compile --install-headers /opt/homebrew/include/python3.9/pyodbc
         cwd: /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/
    Complete output (27 lines):
    /opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py:669: UserWarning: Usage of dash-separated 'library-dirs' will not be supported in future versions. Please use the underscore name 'library_dirs' instead
      warnings.warn(
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    creating build
    creating build/temp.macosx-11-arm64-3.9
    creating build/temp.macosx-11-arm64-3.9/src
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/buffer.cpp -o build/temp.macosx-11-arm64-3.9/src/buffer.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/cnxninfo.cpp -o build/temp.macosx-11-arm64-3.9/src/cnxninfo.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/connection.cpp -o build/temp.macosx-11-arm64-3.9/src/connection.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/cursor.cpp -o build/temp.macosx-11-arm64-3.9/src/cursor.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/errors.cpp -o build/temp.macosx-11-arm64-3.9/src/errors.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/getdata.cpp -o build/temp.macosx-11-arm64-3.9/src/getdata.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/params.cpp -o build/temp.macosx-11-arm64-3.9/src/params.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbccompat.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbccompat.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbcdbg.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbcdbg.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbcmodule.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbcmodule.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/row.cpp -o build/temp.macosx-11-arm64-3.9/src/row.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/textenc.cpp -o build/temp.macosx-11-arm64-3.9/src/textenc.o -Wno-write-strings -Wno-deprecated-declarations
    creating build/lib.macosx-11-arm64-3.9
    clang++ -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/opt/homebrew/Cellar/unixodbc/2.3.9/lib -I/opt/homebrew/Cellar/unixodbc/2.3.9/include build/temp.macosx-11-arm64-3.9/src/buffer.o build/temp.macosx-11-arm64-3.9/src/cnxninfo.o build/temp.macosx-11-arm64-3.9/src/connection.o build/temp.macosx-11-arm64-3.9/src/cursor.o build/temp.macosx-11-arm64-3.9/src/errors.o build/temp.macosx-11-arm64-3.9/src/getdata.o build/temp.macosx-11-arm64-3.9/src/params.o build/temp.macosx-11-arm64-3.9/src/pyodbccompat.o build/temp.macosx-11-arm64-3.9/src/pyodbcdbg.o build/temp.macosx-11-arm64-3.9/src/pyodbcmodule.o build/temp.macosx-11-arm64-3.9/src/row.o build/temp.macosx-11-arm64-3.9/src/textenc.o -L/usr/local/lib -L/usr/lib -L/usr/local/lib -lodbc -o build/lib.macosx-11-arm64-3.9/pyodbc.cpython-39-darwin.so
    ld: warning: directory not found for option '-L/opt/homebrew/Cellar/unixodbc/2.3.9/lib'
    ld: library not found for -lodbc
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/clang++' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/homebrew/opt/[email protected]/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"'; __file__='"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-record-axaz51v3/install-record.txt --single-version-externally-managed --compile --install-headers /opt/homebrew/include/python3.9/pyodbc Check the logs for full command output.

preske87 avatar May 09 '21 12:05 preske87

Hello,

same and weird issue. Installation in my M1 Mac Mini was working fine. Now attempting to install pyodbc on M1 Macbook Air results in error

philipp@Air-von-Philipp bin % brew install unixodbc
Warning: unixodbc 2.3.9_1 is already installed and up-to-date.
To reinstall 2.3.9_1, run:
  brew reinstall unixodbc
philipp@Air-von-Philipp bin % export LDFLAGS="-L/opt/homebrew/Cellar/unixodbc/2.3.9/lib"
philipp@Air-von-Philipp bin % export CPPFLAGS="-I/opt/homebrew/Cellar/unixodbc/2.3.9/include"
philipp@Air-von-Philipp bin % ./python3 -m pip install pyodbc                                
Collecting pyodbc
  Using cached pyodbc-4.0.30.tar.gz (266 kB)
Building wheels for collected packages: pyodbc
  Building wheel for pyodbc (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/homebrew/opt/[email protected]/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"'; __file__='"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-wheel-jvs3kf9i
       cwd: /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/
  Complete output (27 lines):
  /opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py:669: UserWarning: Usage of dash-separated 'library-dirs' will not be supported in future versions. Please use the underscore name 'library_dirs' instead
    warnings.warn(
  running bdist_wheel
  running build
  running build_ext
  building 'pyodbc' extension
  creating build
  creating build/temp.macosx-11-arm64-3.9
  creating build/temp.macosx-11-arm64-3.9/src
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/buffer.cpp -o build/temp.macosx-11-arm64-3.9/src/buffer.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/cnxninfo.cpp -o build/temp.macosx-11-arm64-3.9/src/cnxninfo.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/connection.cpp -o build/temp.macosx-11-arm64-3.9/src/connection.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/cursor.cpp -o build/temp.macosx-11-arm64-3.9/src/cursor.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/errors.cpp -o build/temp.macosx-11-arm64-3.9/src/errors.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/getdata.cpp -o build/temp.macosx-11-arm64-3.9/src/getdata.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/params.cpp -o build/temp.macosx-11-arm64-3.9/src/params.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbccompat.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbccompat.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbcdbg.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbcdbg.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbcmodule.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbcmodule.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/row.cpp -o build/temp.macosx-11-arm64-3.9/src/row.o -Wno-write-strings -Wno-deprecated-declarations
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/textenc.cpp -o build/temp.macosx-11-arm64-3.9/src/textenc.o -Wno-write-strings -Wno-deprecated-declarations
  creating build/lib.macosx-11-arm64-3.9
  clang++ -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/opt/homebrew/Cellar/unixodbc/2.3.9/lib -I/opt/homebrew/Cellar/unixodbc/2.3.9/include build/temp.macosx-11-arm64-3.9/src/buffer.o build/temp.macosx-11-arm64-3.9/src/cnxninfo.o build/temp.macosx-11-arm64-3.9/src/connection.o build/temp.macosx-11-arm64-3.9/src/cursor.o build/temp.macosx-11-arm64-3.9/src/errors.o build/temp.macosx-11-arm64-3.9/src/getdata.o build/temp.macosx-11-arm64-3.9/src/params.o build/temp.macosx-11-arm64-3.9/src/pyodbccompat.o build/temp.macosx-11-arm64-3.9/src/pyodbcdbg.o build/temp.macosx-11-arm64-3.9/src/pyodbcmodule.o build/temp.macosx-11-arm64-3.9/src/row.o build/temp.macosx-11-arm64-3.9/src/textenc.o -L/usr/local/lib -L/usr/lib -L/usr/local/lib -lodbc -o build/lib.macosx-11-arm64-3.9/pyodbc.cpython-39-darwin.so
  ld: warning: directory not found for option '-L/opt/homebrew/Cellar/unixodbc/2.3.9/lib'
  ld: library not found for -lodbc
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command '/usr/bin/clang++' failed with exit code 1
  ----------------------------------------
  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: Command errored out with exit status 1:
     command: /opt/homebrew/opt/[email protected]/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"'; __file__='"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-record-axaz51v3/install-record.txt --single-version-externally-managed --compile --install-headers /opt/homebrew/include/python3.9/pyodbc
         cwd: /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/
    Complete output (27 lines):
    /opt/homebrew/lib/python3.9/site-packages/setuptools/dist.py:669: UserWarning: Usage of dash-separated 'library-dirs' will not be supported in future versions. Please use the underscore name 'library_dirs' instead
      warnings.warn(
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    creating build
    creating build/temp.macosx-11-arm64-3.9
    creating build/temp.macosx-11-arm64-3.9/src
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/buffer.cpp -o build/temp.macosx-11-arm64-3.9/src/buffer.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/cnxninfo.cpp -o build/temp.macosx-11-arm64-3.9/src/cnxninfo.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/connection.cpp -o build/temp.macosx-11-arm64-3.9/src/connection.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/cursor.cpp -o build/temp.macosx-11-arm64-3.9/src/cursor.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/errors.cpp -o build/temp.macosx-11-arm64-3.9/src/errors.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/getdata.cpp -o build/temp.macosx-11-arm64-3.9/src/getdata.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/params.cpp -o build/temp.macosx-11-arm64-3.9/src/params.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbccompat.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbccompat.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbcdbg.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbcdbg.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/pyodbcmodule.cpp -o build/temp.macosx-11-arm64-3.9/src/pyodbcmodule.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/row.cpp -o build/temp.macosx-11-arm64-3.9/src/row.o -Wno-write-strings -Wno-deprecated-declarations
    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/Cellar/unixodbc/2.3.9/include -DPYODBC_VERSION=4.0.30 -UMAC_OS_X_VERSION_10_7 -I/opt/homebrew/include -I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c src/textenc.cpp -o build/temp.macosx-11-arm64-3.9/src/textenc.o -Wno-write-strings -Wno-deprecated-declarations
    creating build/lib.macosx-11-arm64-3.9
    clang++ -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -L/opt/homebrew/Cellar/unixodbc/2.3.9/lib -I/opt/homebrew/Cellar/unixodbc/2.3.9/include build/temp.macosx-11-arm64-3.9/src/buffer.o build/temp.macosx-11-arm64-3.9/src/cnxninfo.o build/temp.macosx-11-arm64-3.9/src/connection.o build/temp.macosx-11-arm64-3.9/src/cursor.o build/temp.macosx-11-arm64-3.9/src/errors.o build/temp.macosx-11-arm64-3.9/src/getdata.o build/temp.macosx-11-arm64-3.9/src/params.o build/temp.macosx-11-arm64-3.9/src/pyodbccompat.o build/temp.macosx-11-arm64-3.9/src/pyodbcdbg.o build/temp.macosx-11-arm64-3.9/src/pyodbcmodule.o build/temp.macosx-11-arm64-3.9/src/row.o build/temp.macosx-11-arm64-3.9/src/textenc.o -L/usr/local/lib -L/usr/lib -L/usr/local/lib -lodbc -o build/lib.macosx-11-arm64-3.9/pyodbc.cpython-39-darwin.so
    ld: warning: directory not found for option '-L/opt/homebrew/Cellar/unixodbc/2.3.9/lib'
    ld: library not found for -lodbc
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command '/usr/bin/clang++' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/homebrew/opt/[email protected]/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"'; __file__='"'"'/private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-install-g4_8mhh3/pyodbc_22c0b0b00fb04cce958d2ba3342d2ea4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/2r/8hjh8rp56lg9_rbzhclms3q80000gn/T/pip-record-axaz51v3/install-record.txt --single-version-externally-managed --compile --install-headers /opt/homebrew/include/python3.9/pyodbc Check the logs for full command output.

@preske87 if you are using the brew version of the Python 3.9.5 or the default 3.8 version of Python. They are having some bug. I fixed this by uninstalling the brew version of Python and installing python 3.9.5 graphical from Python website.

Maybe this would fix the issue

Ritish-Madan avatar May 09 '21 15:05 Ritish-Madan

Thanks @michalpulpan. I can confirm that the following works on my MacBook M1:

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

pip is here an aliased to /opt/homebrew/bin/pip3

I did install the unixODBC using Homebrew. And I have the Python installed using the Graphic Installer, instead of Homebrew installation of Python.

I don't know if it is creating the problem, but installing the unixodbc is still throwing the same error after importing pyodbc

I did also tried using brew install python3, but Homebrew version of python do not install the other libraries like Pandas, Numpy, Pyodbc too. So I installed the Python3 graphically and got all the other libraries installed.

I have MacBook Air M1

Do I have to install the Homebrew version of python3?

I solved this issue using the soft linking to unixODBC folder, as I have unix odbc from brew and Python3 from Graphical installation . But the the error arrises that states that architecture is not compatible.

Ritish-Madan avatar May 09 '21 15:05 Ritish-Madan

But the the error arrises that states that architecture is not compatible.

That occurs if you are mixing ARM and x86 binaries. Note that unless you have native ARM ODBC drivers available that you can use with pyODBC, everything should "just work" if you have a consistently x86 environment and use Rosetta2 emulation instead.

v-chojas avatar May 10 '21 14:05 v-chojas

Just tried again:

  • downloaded and installed Python 3.9.5
  • created venv
  • sourced / activated venv
  • executed pip install pyodbc
  • started interactive python shell and tried to import
(test) philipp@Air-von-Philipp python_venv_test % pip install pyodbc
Collecting pyodbc
  Using cached pyodbc-4.0.30-cp39-cp39-macosx_10_9_x86_64.whl (63 kB)
Installing collected packages: pyodbc
Successfully installed pyodbc-4.0.30
(test) philipp@Air-von-Philipp python_venv_test % python --version
Python 3.9.5
(test) philipp@Air-von-Philipp python_venv_test % python
Python 3.9.5 (v3.9.5:0a7dcbdb13, May  3 2021, 13:17:02) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/philipp/Desktop/python_venv_test/test/lib/python3.9/site-packages/pyodbc.cpython-39-darwin.so, 2): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
  Referenced from: /Users/philipp/Desktop/python_venv_test/test/lib/python3.9/site-packages/pyodbc.cpython-39-darwin.so
  Reason: image not found

preske87 avatar May 10 '21 16:05 preske87

Yep that's the issue with the Mac M1 Silicon Built MacBooks. The PyODBC I guess is not yet supported as when I try to create a soft link with the UniXODBC, it shows Architecture not compatible

Ritish-Madan avatar May 10 '21 16:05 Ritish-Madan

Do anyone here is using PyODBC on Mac M1 silicon processor?

Ritish-Madan avatar May 10 '21 16:05 Ritish-Madan

macosx_10_9_x86_64.whl

That's the x86 version. You'll also need the x86 version of unixODBC installed in order to use it.

v-chojas avatar May 10 '21 16:05 v-chojas

OK, I am using pymssqland this runs smoothly

preske87 avatar May 10 '21 16:05 preske87

macosx_10_9_x86_64.whl

That's the x86 version. You'll also need the x86 version of unixODBC installed in order to use it.

So, any idea how we can install the same if it is already available?

Ritish-Madan avatar May 10 '21 16:05 Ritish-Madan

OK, I am using pymssqland this runs smoothly

@preske87 Are you using it on MacBook M1? And how did you install the Python3 build? Using brew or Graphical Installation? What is the version of your python3? Actually I am facing No Module found in pymssql as well

Ritish-Madan avatar May 11 '21 01:05 Ritish-Madan

OK, I am using pymssqland this runs smoothly

@preske87 Are you using it on MacBook M1? And how did you install the Python3 build? Using brew or Graphical Installation? What is the version of your python3? Actually I am facing No Module found in pymssql as well

Ritish-Madan avatar May 11 '21 01:05 Ritish-Madan

OK, I am using pymssqland this runs smoothly

@preske87 Are you using it on MacBook M1? And how did you install the Python3 build? Using brew or Graphical Installation? What is the version of your python3? Actually I am facing No Module found in pymssql as well

@Ritish-Madan Yes, am using MacBook M1 and MacMini M1. I have 2 python3 installed:

  • the brew package /opt/homebrew/bin/python3 in version 3.9.1
  • the standard package (installed through pkg / graphical installer) /usr/bin/python3version 3.8.2

Only for the brew pymssqlcould be used. I needed to run brew install freetds and /opt/homebrew/bin/python3 -m pip install pymssqlprior

preske87 avatar May 11 '21 06:05 preske87

Do anyone here is using PyODBC on Mac M1 silicon processor?

Yes, docker using plattform linux/amd64

angelhurst avatar May 19 '21 03:05 angelhurst