none
How to solve python package error DLL load failed: %1 is not a valid Win32 application?

    Question

  • I'm using the django framework in Visual Studio 2015 with python 2.7 and i'm trying to import an opencv file called cv2, the system recognizes its there but I keep getting the error %1 is not a valid Win32 application. My system is a 64 bit system but all the wheel files I install using pip only successfully installs if it is a 32 bit version not a 64 bit version. I've looked at other posts on other websites but those solutions don't work for me. The urls: http://stackoverflow.com/questions/19019720/importerror-dll-load-failed-1-is-not-a-valid-win32-application-but-the-dlls?noredirect=1, http://stackoverflow.com/questions/19019720/importerror-dll-load-failed-1-is-not-a-valid-win32-application-but-the-dlls

    I've also tried creating different python environments with a 32 bit version and a 64 bit version but still no success in addition to uninstalling different packages of opencv from different sources and syncing the intelli-sense db in my project. 

    Here are the opencv files that installed:

    This is the picture of the python environments I created in visual studio django project: 

    If more information is required to solve the problem, please let me know. Thanks

    Sunday, March 12, 2017 10:06 PM

Answers

  • Hi friend,

    Welcome to MSDN forum.

    Sorry about you are experiencing this issue.

    At first I was thinking if it may be the issue 32 bit or 64 bit version of python or OpenCV, but it seems not, since you’ve tried both of them according to the thread you shared.

    So I wonder if it’s the error message’s misleading, and this did happen to someone else, the real error is the OpenCV DLLs cannot be found. To resolve this issue, you could add the OpenCV binaries to the Windows PATH environment variable (opencv binaries path, eg ” C:\opencv\build\bin\Release” ) by following steps:

    Control panel -> System and security -> System -> Advanced system settings->  Environment Variables :

    You could click New button to add it.

    Then restart VS.

    Reference thread:

    http://stackoverflow.com/questions/14629818/importerror-dll-load-failed-1-is-not-a-valid-win32-application

    Not sure if this could absolutely work for you, but it’s worth trying.

    Hope it’s helpful.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 14, 2017 4:37 PM

All replies

  • Hi friend,

    Welcome to MSDN forum.

    Sorry about you are experiencing this issue.

    At first I was thinking if it may be the issue 32 bit or 64 bit version of python or OpenCV, but it seems not, since you’ve tried both of them according to the thread you shared.

    So I wonder if it’s the error message’s misleading, and this did happen to someone else, the real error is the OpenCV DLLs cannot be found. To resolve this issue, you could add the OpenCV binaries to the Windows PATH environment variable (opencv binaries path, eg ” C:\opencv\build\bin\Release” ) by following steps:

    Control panel -> System and security -> System -> Advanced system settings->  Environment Variables :

    You could click New button to add it.

    Then restart VS.

    Reference thread:

    http://stackoverflow.com/questions/14629818/importerror-dll-load-failed-1-is-not-a-valid-win32-application

    Not sure if this could absolutely work for you, but it’s worth trying.

    Hope it’s helpful.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 14, 2017 4:37 PM
  • Thanks for the response, this solved my problem
    Saturday, March 18, 2017 8:08 PM
  • Could you please make the steps a little clearer, please.  Newbie and not sure what I should add to the path??
    • Edited by ingham02 Tuesday, July 10, 2018 1:44 AM
    Tuesday, July 10, 2018 1:41 AM