2

I am trying to import pymssql and I am getting this error (I think I have installed it correctly):

Traceback (most recent call last):
File "sql.py", line 1, in <module>
    import pymssql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymssql.so, 2): Symbol not found: _dbversion
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymssql.so
  Expected in: dynamic lookup

How do I solve this?

Mark Collier
  • 51
  • 1
  • 4

1 Answers1

2

The symbol was not found on import, possibly due to a linking problem at compilation when setup.py was run.

I ran into this particular issue because I was running 32-bit Python 2.7.12 on my OS X machine. Doing the following resolved the issue for me:

You need FreeTDS for the build to succeed, and if you don't build with the proper architecture, it is possible you will run into this error.

Hope this helps!

Community
  • 1
  • 1
tterry
  • 339
  • 4
  • 8
  • 1
    2020 update: I don't think this solution is possible any longer: [FreeTDS 0.91 is no longer available on homebrew](https://formulae.brew.sh/formula/freetds) and [pymssql is no longer maintained, so version 2.20 will never happen](https://github.com/pymssql/pymssql/issues/668). With the scuttling of pymssql, the real answer now is probably to stop using it. – tterry Jul 16 '20 at 21:02
  • uninstall and install freetds back helped. ```` brew install freetds ``` – Dugini Vijay Dec 22 '20 at 19:21