Created
January 19, 2017 14:37
-
-
Save rosiecakes/89d3e77c8dded619ed34dc44d25dd33a to your computer and use it in GitHub Desktop.
mac osx pyodbc stupid dumb annoying issue fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Homebrew set up to install to /Users/shimadar/usr/local instead of /usr/local | |
I'm running OSX 10.11.6, Python 3.5.2, pyenv 1.0.6, pyodbc 4.0.1 (via pip). | |
Went through [this][1] and connect fine with both tsql and isql as shown in the walkthrough. | |
Still cannot import pyodbc. | |
>>> import pyodbc | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
ImportError: dlopen(/Users/shimadar/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pyodbc.cpython-35m-darwin.so, 2): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib | |
Referenced from: /Users/shimadar/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pyodbc.cpython-35m-darwin.so | |
Reason: image not found | |
Realized lib path slightly different. | |
$ otool -L /Users/shimadar/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pyodbc.cpython-35m-darwin.so | |
/Users/shimadar/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pyodbc.cpython-35m-darwin.so: | |
/usr/local/opt/unixodbc/lib/libodbc.2.dylib (compatibility version 3.0.0, current version 3.0.0) | |
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0) | |
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0) | |
Changed the path and now it imports. | |
$ install_name_tool -change /usr/local/opt/unixodbc/lib/libodbc.2.dylib /Users/shimadar/usr/local/opt/unixodbc/lib/libodbc.2.dylib /Users/shimadar/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pyodbc.cpython-35m-darwin.so | |
[1]: https://github.com/lionheart/django-pyodbc/wiki/Mac-setup-to-connect-to-a-MS-SQL-Server | |
[2]: http://stackoverflow.com/questions/6383310/python-mysqldb-library-not-loaded-libmysqlclient-18-dylib |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This did help me