Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyodbc import error: DLL load failed: %1 is not a valid Win32 application

Tags:

python

pyodbc

I'm very new to python and all it's wonders and I'm trying to get something someone else wrote to work. Unfortunately, that someone else is no longer available here so I can't go to him in person. I'm now just trying to get the import portion of his code to work and it won't import pyodbc.

I downloaded and ran the installer named pyodbc-3.0.7.win32-py2.7.exe. It dropped some files into my C:\Python27\ArcGIS10.2\Lib\site-packages directory. I then added C:\Python27\ArcGIS10.2\Lib\site-packages to my pythonpath environment variable. I checked that it's there by importing sys and print sys.path and got the below

>>> import sys
>>> print sys.path
['', 'C:\\Python27\\Lib\\idlelib', 'C:\\Python27\\ArcGIS10.2\\Lib\\site-packages', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']

I then type import pyodbc and get the below

 >>> import pyodbc

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
     import pyodbc
ImportError: DLL load failed: %1 is not a valid Win32 application.

I opened up the Path Browser and I was able to find pyodbc.pyd.

like image 538
Tyddlywink Avatar asked Sep 30 '22 19:09

Tyddlywink


1 Answers

This probably happens when you try to import 32 bit libraries on 64 bit python or vice-verso.

like image 61
Vamsi Nerella Avatar answered Oct 06 '22 00:10

Vamsi Nerella