Problem:
Getting this error when trying to import python-tesseract into my project (OCR functionality):
ImportError: DLL load failed: %1 is not a valid Win32 application.
- I do not know what exactly the problem is
- I do not have the skills and knowledge to trace this kind of problem to it's root cause.
Background:
As I understand it, tesseract is a 32 bit application. I am running Windows 7, 64 bit with 64 bit python. Other people seemed to be running tesseract under these conditions, but they are not ideal and could be causing this challenge.
Stack trace
This is the error trace from PyCharm. As you can see, it does not specify the file that was the problem, instead saying it could not find what looks to be string format argument: %1
Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.3\helpers\pydev\pydevd.py", line 1481, in debugger.run(setup['file'], None, None) File "C:\Program Files (x86)\JetBrains\PyCharm 2.7.3\helpers\pydev\pydevd.py", line 1124, in run pydev_imports.execfile(file, globals, locals) #execute the script File "C:/Dropbox/COC/automate/coc_automate/python/__init__.py", line 7, in import tesseract File "C:\Python27\lib\site-packages\tesseract.py", line 28, in _tesseract = swig_import_helper() File "C:\Python27\lib\site-packages\tesseract.py", line 22, in swig_import_helper _mod = imp.load_module('_tesseract', fp, pathname, description) ImportError: DLL load failed: %1 is not a valid Win32 application.
Dependency Walker
Ran dependency walker on the file that seems to be the problem: _tesseract.pyd
and found a few things that seemed strange:
- It cannot find Python27.dll
- Even though I've been successfully using Python for a long time now.
- I verfified that
Python.dll
is located inC:\Windows\System32
on my system
- The file
MSVCR90.DLL
is the wrong CPU version.- it is not found in an "expected" area such as
C:\Windows\System32
, but rather in the program files directory for a niche graphics library that I have installed:c:\program files\graphicsmagick-1.3.18-q8\MSVCR90.DLL
. Could there be issues with the two installations confusing each other?
- it is not found in an "expected" area such as
PYTHON27.DLL Error opening file. The system cannot find the file specified (2). API-MS-WIN-CORE-COM-L1-1-0.DLL The system cannot find the file specified (2). API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL The system cannot find the file specified (2). API-MS-WIN-CORE-WINRT-L1-1-0.DLL The system cannot find the file specified (2). API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL The system cannot find the file specified (2). API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL The system cannot find the file specified (2). API-MS-WIN-SHCORE-SCALING-L1-1-0.DLL The system cannot find the file specified (2). DCOMP.DLL The system cannot find the file specified (2). GPSVC.DLL The system cannot find the file specified (2). IESHIMS.DLL The system cannot find the file specified (2). ... c:\program files\graphicsmagick-1.3.18-q8\MSVCR90.DLL (Seems to be the wrong CPU version) Error: At least one required implicit or forwarded dependency was not found. Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module. Error: Modules with different CPU types were found. Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
Screen shot: