17

I've tried to install pyodbc on mac, but I got this error

Traceback (most recent call last):
  File "Untitled.py", line 1, in <module>
    import pyodbc
ImportError: dlopen(/usr/local/lib/python3.6/site-packages/pyodbc.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
  Referenced from: /usr/local/lib/python3.6/site-packages/pyodbc.cpython-36m-darwin.so
  Reason: image not found

What could it be and how can I solve it?

volkoshkursk
  • 325
  • 1
  • 2
  • 14

3 Answers3

34

See if an installation of unixodbc helps you:

brew install unixodbc
jmd_dk
  • 12,125
  • 9
  • 63
  • 94
rajiv
  • 486
  • 6
  • 9
4

I tried all of the above with no luck. Finally I installed version 4.0.34 of pyodbc along with the unixodbc and now all is well.

brew install unixodbc  
pip install pyodbc==4.0.34
0
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Paste this command in MAC terminal if brew not found. after that - brew install unixodbc

Dharman
  • 30,962
  • 25
  • 85
  • 135