0

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.

Later Edit: I changed the first line to import pypyodbc

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 pypyodbc instead of pyodbc. 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

Robert
  • 439
  • 2
  • 7
  • 14
  • Try [this Link](https://stackoverflow.com/a/47070652/5484278) and run it with python3 insted of python – Ar Win Nov 13 '17 at 07:16
  • thank you @ArWin for this. I have been seeking for a fix. I am trying it out later on, today. – Robert Nov 14 '17 at 15:08

1 Answers1

0

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+https://github.com/mkleehammer/pyodbc@master
Community
  • 1
  • 1
Jérôme
  • 9,435
  • 2
  • 42
  • 73
  • I have followed those steps but I get the same error. – Robert Sep 14 '16 at 14:40
  • So you installed pyobdc for Python3 but can't run import pyobdc in a Python3 interpreter? – Jérôme Sep 14 '16 at 14:41
  • Actually, it failed at 2 parts: `Failed building wheel for pyodbc` and then a long error at the end that pertains to (I think) `error: command '/usr/bin/clang' failed with exit status 1` – Robert Sep 14 '16 at 14:45
  • follow-up comment: `fatal error: 'sql.h' file not found` – Robert Sep 14 '16 at 15:06
  • Searching for those errors lead me to what I think is the root-cause. See edited answer. – Jérôme Sep 14 '16 at 16:09
  • I think I messed up as it worked if I entered `pypyodbc` instead of `pyodbc`. I will edit the post. The only thing I need to solve is the last error: `UnicodeDecodeError: 'utf-32-le' codec can't decode bytes in position 0-1: truncated data` – Robert Sep 14 '16 at 18:15
  • pypyobdc is another obdc module (written in pure Python as opposed to pyobdc). – Jérôme Sep 15 '16 at 07:04