Description
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:
- Python: 3.7.6
- pyodbc: 4.0.28
- OS: macOS 10.14.4
- driver: freetds
Issue
When importing pyodbc
❯ python
>>> import pyodbc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/pcosta/Documents/test/myenv/lib/python3.7/site-packages/pyodbc.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
Referenced from: /Users/pcosta/Documents/test/myenv/lib/python3.7/site-packages/pyodbc.cpython-37m-darwin.so
Reason: image not found
I know why this is happening, as I don't have libodbc.2.dylib
in the expected location. The reason is I do not have permission to write to /usr/local/
, so I have Homebrew installing into ~/.brew
. This mostly works fine. I am even able to get both tsql
and isql
working as expected by following the steps outlined here: https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Mac-OSX.
So I do have libodbc.2.dylib
, it's just that it lives in /Users/pcosta/.brew/opt/unixodbc/lib
, not /usr/local/opt/unixodbc/lib
.
The main questions is can I get pyodbc to look for libodbc.2.dylib
(and other associated files) in another directory?
I have all the files needed and have configured them correctly, I just need to repoint pyodbc somehow.
Thanks!