ImportError: DLL load failed: %1 is not a valid Win32 application. But the DLL's are there

前端 未结 21 1195
礼貌的吻别
礼貌的吻别 2020-11-22 14:12

I have a situation very much like the one at ImportError: DLL load failed: %1 is not a valid Win32 application, but the answer there isn\'t working for me.

My Python

相关标签:
21条回答
  • 2020-11-22 15:01

    Please check if the python version you are using is also 64 bit. If not then that could be the issue. You would be using a 32 bit python version and would have installed a 64 bit binaries for the OPENCV library.

    0 讨论(0)
  • 2020-11-22 15:01

    Wow, I found yet another case for this problem. None of the above worked. Eventually I used python's ability to introspect what was being loaded. For python 2.7 this means:

    import imp
    imp.find_module("cv2")
    

    This turned up a completely unexpected "cv2.pyd" file in an Anaconda DLL directory that wasn't touched by multiple uninstall/install attempts. Python was looking there first and not finding my good installation. I deleted that cv2.pyd file and tried imp.find_module("cv2") again and python immediately found the right file and cv2 started working.

    So if none of the other solutions work for you, make sure you use python introspection to see what file python is trying to load.

    0 讨论(0)
  • 2020-11-22 15:02

    In my case, I have 64bit python, and it was lxml that was the wrong version--I should have been using the x64 version of that as well. I solved this by downloading the 64-bit version of lxml here:

    https://pypi.python.org/pypi/lxml/3.4.1

    lxml-3.4.1.win-amd64-py2.7.exe
    

    This was the simplest answer to a frustrating issue.

    0 讨论(0)
提交回复
热议问题