我在MacOS上安装了Pyodbc和SQL驱动程序:
brew list msodbcsql18
/opt/homebrew/Cellar/msodbcsql18/18.0.1.1/.brew_home/Library/Python/2.7/lib/python/site-packages/homebrew.pth
/opt/homebrew/Cellar/msodbcsql18/18.0.1.1/.brew_home/.bazelrc
/opt/homebrew/Cellar/msodbcsql18/18.0.1.1/include/msodbcsql18/msodbcsql.h
/opt/homebrew/Cellar/msodbcsql18/18.0.1.1/lib/libmsodbcsql.18.dylib
/opt/homebrew/Cellar/msodbcsql18/18.0.1.1/odbcinst.ini
/opt/homebrew/Cellar/msodbcsql18/18.0.1.1/share/doc/ (2 files)
/opt/homebrew/Cellar/msodbcsql18/18.0.1.1/share/msodbcsql18/resources/en_US/msodbcsqlr18.rll
brew list unixodbc
/opt/homebrew/Cellar/unixodbc/2.3.9_1/.bottle/etc/ (2 files)
/opt/homebrew/Cellar/unixodbc/2.3.9_1/bin/dltest
/opt/homebrew/Cellar/unixodbc/2.3.9_1/bin/isql
/opt/homebrew/Cellar/unixodbc/2.3.9_1/bin/iusql
/opt/homebrew/Cellar/unixodbc/2.3.9_1/bin/odbc_config
/opt/homebrew/Cellar/unixodbc/2.3.9_1/bin/odbcinst
/opt/homebrew/Cellar/unixodbc/2.3.9_1/bin/slencheck
/opt/homebrew/Cellar/unixodbc/2.3.9_1/include/ (11 files)
/opt/homebrew/Cellar/unixodbc/2.3.9_1/lib/libodbc.2.dylib
/opt/homebrew/Cellar/unixodbc/2.3.9_1/lib/libodbccr.2.dylib
/opt/homebrew/Cellar/unixodbc/2.3.9_1/lib/libodbcinst.2.dylib
/opt/homebrew/Cellar/unixodbc/2.3.9_1/lib/pkgconfig/ (3 files)
/opt/homebrew/Cellar/unixodbc/2.3.9_1/lib/ (6 other files)
/opt/homebrew/Cellar/unixodbc/2.3.9_1/share/man/ (8 files)
pip show pyodbc
Name: pyodbc
Version: 4.0.32
Summary: DB API Module for ODBC
Home-page: https://github.com/mkleehammer/pyodbc
Author:
Author-email:
License: MIT
Location: /Users/deniz/Anaconda/anaconda3/lib/python3.9/site-packages
Requires:
Required-by:
❯ python3
Python 3.9.7 (default, Sep 16 2021, 08:50:36)
[Clang 10.0.0 ] :: Anaconda, Inc. 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/deniz/Anaconda/anaconda3/lib/python3.9/site-packages/pyodbc.cpython-39-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
Referenced from: /Users/deniz/Anaconda/anaconda3/lib/python3.9/site-packages/pyodbc.cpython-39-darwin.so
Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file)
如何解决这个问题?
您的机器缺少unixodbc
。
使用下面的命令来安装它,它应该可以正常工作。
brew install unixodbc