How to install pyodbc 64-bit?

15,708

Solution 1

There is a list of "unofficial" Python modules here

PyODBC is one of those that have been compiled for 64bits.

Also, make sure you're using the correct version of the ODBC Administrator. The default will be for 64bit drivers, but you can use 32bit drivers with %windir%\SysWOW64\odbcad32.exe

Solution 2

I spend a lot time to find out why pyodbc can't see 64 bit ODBC driver because I confused between bitness of Windows. So I will make it clear that

Python 32 bit + pyodbc 32 bit (default when install from pip) will read driver from %windir%\SysWOW64\odbcad32.exe

Python 64 bit + pyodbc 64 bit (you have to download from here) will read driver from %windir%\System32\odbcad32.exe

Share:
15,708
aensm
Author by

aensm

Updated on June 05, 2022

Comments

  • aensm
    aensm almost 2 years

    I have Python 2.7, MySQL 5.5, MySQL ODBC Connector 5.1, and pyodbc all installed on my computer, which is running Windows 7, 64-bit...

    Only problem is that everything is installed as 64-bit except pyodbc, which is 32-bit.

    When using easy_install to download pyodbc, it automatically downloads the 32-bit version. Thus, when I try to connect to my database using:

    cnxn = pyodbc.connect('DRIVER={MySQL ODBC 5.1 DRIVER};SERVER=localhost;DATABASE=test;UID=root;PWD=password')
    

    I get the error:

    Data source name not found and no default driver specified (0) (SQLDriverConnect)
    

    And when I try to specify a DSN with:

    cnxn = pyodbc.connect('DSN=dsn_name;etc...')
    

    I get the error:

    The specified DSN contains an architecture mismatch between the Driver and Application (0) (SQLDriverConnect)
    

    This link tells me that this is due to the 32/64-bit mismatch, as expected: http://msdn.microsoft.com/en-us/library/windows/desktop/ms712362(v=vs.85).aspx

    So I have two questions:

    1) Is it possible to force easy_install to download the 64-bit pyodbc, or is it possible to download the 64-bit pyodbc manually?

    2) If the above is not possible, is it possible to configure the DSN to allow for this using the Microsoft ODBC Data Source Administrator window.

    Thanks.