Robert Robert - 4 months ago 79
Python Question

pyodbc module does not work with Python3

I have just transitioned to a Mac (from Win) and I cannot find the proper way to make a script work (it did on Win).

I am using

import pyodbc
on the first line and I get the "No module .." error.

If I enter the workspace in the preexistent python version (2.7.10) I can import the module but the script fails with:

pyodbc.Error: ('00000', '[00000] [iODBC][Driver Manager]dlopen({SQL Server}, 6): image not found (0) (SQLDriverConnect)')

I want to use python3 anyway.

If I enter python3, when trying to import the module I get an error.

My main problem is that I an not sure how to find where the problem is. Can anyone help with this?

Later Edit

It worked if I used
instead of
. It imports the module and the only thing left to solve is the decoding part:
UnicodeDecodeError: 'utf-32-le' codec can't decode bytes in position 0-1: truncated data


Module pyobdc is distributed for Python3. You can check that on its PyPi page.

Did you actually install it for Python3?

Python packages are installed separately for each Python instance on your machine. (In fact, you may even use virtual environments to create multiple environments for one Python installation, which can be useful if you need to run several applications with dependencies on different versions of the same library.)

To install a package using pip for Python3 on a Mac with also Python2 installed, see this question.

Edit: installation issue

Your problem seems to be related to this issue in pyodbc.

The fix is in master but not released on Pypi. You may try to install the latest version from master branch.

Should be:

pip install git+