Pyodbc - The specified DSN contains an architecture mismatch between the Driver and Application

安稳与你 提交于 2019-12-10 18:45:44

问题


I'm trying to connect to a MS Access Database (.accdb file) via python.

I used pyodbc to do this connection:

import pyodbc
conn = pyodbc.connect("DRIVER = {Microsoft Access Driver (*.mdb, *.accdb)}; DBG=C:\\test_db.accdb")

However, I got the following error:

('IM002, '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')

I went to the ODBC Data Source Administrator and when I tried to configure or remove the Driver I got the message:

Errors Found:
The specified DSN contains an architecture mismatch between the Driver and Application

I found that this error is provoked by an incompatibility between versions of Windows (windows 7 - 64bit) and Microsoft Access (Office 2010 - 32bits). I tried to reinstall the driver several times, both with 32 and 64bit versions but the problem wasn't solved. Could you please help me to solve this problem? Thank you in advance.


回答1:


You have to make sure the Python version matches the ODBC driver version: 32-bit with 32-bit, 64-bit with 64-bit.

It looks like you have 64-bit Python / pyodbc and 32-bit MS Access.

What you'll need to do is install the 32-bit Python version, and then install pyodbc.

Good luck!



来源:https://stackoverflow.com/questions/36965600/pyodbc-the-specified-dsn-contains-an-architecture-mismatch-between-the-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!