在Mac上安装PyoDBC和UnixODBC
我已经看过 pypyodbc:pypyodbc:pypyodbc:pypyodbc:无法打开lib“ freetds”:未找到文件”)试图连接到sql server 的错误,但是。现在将东西放在不同的
吗
?
connection = pyodbc.connect(connection_string)
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libtdsodbc.so' : file not found (0) (SQLDriverConnect)")
地方 显然是错误的,因为libtdsodbc在/opt/homebrew/lib
我尝试编辑odbcinst.ini
,但我不确定应该在哪里生活。 t一个在 /etc中,或a /etc /unixoDBC目录...当我创建一个时,似乎不读取,因为它仍然抱怨 /usr /usr /local /lib ...
eta:这是在新的MacBook上,在其中一种新的M1芯片上。
I've seen Pypyodbc: Can't open lib 'FreeTDS' : file not found") error when trying to connect to SQL server, but. that's 7 years old, and doesn't seem to be working for me, possibly because brew appears to be putting things in different places now?
I've used brew to install unixodbc, it's in /opt/homebrew/Cellar
.
When I do pip install pyodbc, it appears to work, but I get:
connection = pyodbc.connect(connection_string)
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/usr/local/lib/libtdsodbc.so' : file not found (0) (SQLDriverConnect)")
which is obviously wrong, because libtdsodbc is in /opt/homebrew/lib
I tried editing odbcinst.ini
, but I'm not sure where that's supposed to live. There wasn't one in /etc, or a /etc/unixODBC directory... and when I create either one, the don't seem to be read, because it still complains about /usr/local/lib...
ETA: This is on a new Macbook, so on one of the new M1 chips.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
注意:这是一个糟糕的答案,希望能吸引一个好的答案,但从技术上来说它似乎是有效的。
Homebrew for M1 将所有内容安装在
/opt/homebrew
中。其他一切都需要在/usr/local
中。在新计算机上,/usr/local/lib
甚至不存在。所以我做了这非常糟糕,我知道但这是我目前想出的解决这个问题的唯一方法。也许有什么东西没有赶上M1?我不知道。
Note: This is a BAD answer in the hopes of attracting a good one, but it technically seems to be working.
Homebrew for M1 installs everything in
/opt/homebrew
. Everything else expects things in/usr/local
. On a new computer,/usr/local/lib
didn't even exist. So I didTHIS IS VERY BAD AND I KNOW IT But it's the only way I've figured out currently to deal with the problem. Maybe something hasn't caught up to M1? I'm not sure.
更好的解决方案:
BETTER solution:
有一个拉取请求已经被 pyodbc 维护者忽略了 13 个月:https: //github.com/mkleehammer/pyodbc/pull/870
您可以使用此命令安装分叉版本(可能需要卸载以前的版本或添加额外的参数来强制重新安装)
There is a pull request that has been pretty much ignored for 13 months now by the pyodbc maintainer: https://github.com/mkleehammer/pyodbc/pull/870
You can install the forked version with this command (might need to uninstall the previous version or add extra arguments to force reinstall)
因此,Unix ODBC 将其 ODBC 驱动程序移至
/usr/lib/libiodbcinst.2.dylib
。参见:https://packages.debian.org/sid/libodbcinst2打开ODBC驱动配置文件。添加以下行或类似内容,具体取决于您的 ODBC 安装位置:
ODBCInstLib=libiodbcinst.2.dylib
这可确保 ODBC 驱动程序使用正确的 iODBC 库 (/usr/lib/libiodbcinst.2.dylib) 。
您的驱动程序配置应如下所示:
失败此安装 unix ODBC 手动安装到您想要的任何位置并指向那里!
So Unix ODBC had its ODBC drivers moved to
/usr/lib/libiodbcinst.2.dylib
. See: https://packages.debian.org/sid/libodbcinst2Open the ODBC driver configuration file. Add the following line or similar depending where your ODBC installation is at:
ODBCInstLib=libiodbcinst.2.dylib
This ensures the ODBC driver uses the correct iODBC library (/usr/lib/libiodbcinst.2.dylib).
Your driver configuration should look like this:
Failing this install unix ODBC manually wherever you want and point the refs there!!