rohit2219
rohit2219

Reputation: 248

python 3.3.5 and pyodbc 2.1.7

I'm a beginner in Python.

I have a linux Redhat 4.4 server.It has python2.6 by default. I installed pyodbc 2.1.7 and python 3 tried "import pyodbc" in python3. I got the error below.

1)Is there something like pyodbc 2.1.7 is not compatiable with python3 ? I checked the documentation for pyodbc, but did not find anything conclusive. rpm was used to install pyodbc.

2) Is pypyodbc a good workaround in this case for working with python3(like anyone has any bad experience)? I tried using pypyodbc and basic select and all works with python3 with some workaround.

Python 2.6.6 [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

$ import sys

$ import pyodbc

$ exit()

Python 3.3.5 (default, Mar 13 2014, 20:11:10) [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux

$ import sys

$ import pyodbc

Traceback (most recent call last): File "", line 1, in ImportError: dynamic module does not define init function (PyInit_pyodbc)

Upvotes: 2

Views: 391

Answers (2)

Andy K
Andy K

Reputation: 5044

I did a try with the following and it did the trick

virtualenv vtest -- for testing purpose. Do not use it in your case

source vtest/bin/activate -- for testing purpose. Do not use it in your case

pip3 install pyodbc

Then execute your python3

import pyodbc

Make sure you are using pip3

Upvotes: 2

apex-meme-lord
apex-meme-lord

Reputation: 371

  1. There shouldn't be any compatibility issues between Python3 and pyodbc. That being said, there appears to have been some issues with the odbc binaries in the npm package. I recommend you install unixodbc-dev from npm and pyodbc from pip separately.

Upvotes: 1

Related Questions