How To Fix Python Error ImportError: DLL Load Failed: %1 Is Not A Valid Win32 Application.

When I run a python program in my eclipse Pydev project, I meet an error message ImportError: DLL load failed: %1 is not a valid Win32 application. This error occurs when I use the python sqlite3 module in my program. This article will tell you how to fix it.

1. How To Fix ImportError: DLL load failed: %1 is not a valid Win32 application.

  1. Below is the detailed error message stacktrace.
    Traceback (most recent call last):
      File "C:\WorkSpace\Work\\PythonExampleProject\com\dev2qa\example\sqlite\", line 7, in <module>
        import sqlite3
      File "C:\Program Files (x86)\Python37-32\lib\sqlite3\", line 23, in <module>
        from sqlite3.dbapi2 import *
      File "C:\Program Files (x86)\Python37-32\lib\sqlite3\", line 27, in <module>
        from _sqlite3 import *
    ImportError: DLL load failed: %1 is not a valid Win32 application.
  2. The reason for this error is because my eclipse Pydev project used python interpreter is a 32-bit version, and my Windows OS is a 64-bit version.
  3. Open a dos window and run the command python in it, then you can find the python bit version.
    Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
  4. Run the command set pro in the dos window, you can get your Windows OS bit version.
    >set pro
    PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
    PROGRAMFILES=C:\Program Files
    PROGRAMFILES(X86)=C:\Program Files (x86)
    PROGRAMW6432=C:\Program Files
    PROMPT=(base) $P$G
  5. Now you should remove the 32-bit python and install another 64-bit python and use the 64-bit version of python as your eclipse Pydev project’s python interpreter to fix this problem.
  6. I have installed anaconda on my Windows OS, and the anaconda built-in python is the 64-bit version, so what I need to do is just use the anaconda python as my eclipse Pydev project python interpreter, now I will tell you how to do it.

2. How To Set 64-bit Python As Eclipse Pydev Project Used Python Interpreter.

  1. Open eclipse, click the Project —> Properties menu item on the top menu toolbar.
  2. Click the PyDev – Interpreter/Grammar item on the project Properties window left side.
  3. Click the link Click here to configure an interpreter not listed on the window right side, then it will prompt the How to config interpreter? dialog.
  4. Click the Open interpreter preferences page button, it will open the Preferences window.
  5. On the window right side, click the New button, then click the Browse for python/pypy exe item in the drop-down list.
  6. Browse to select the Python.exe file in my anaconda installed directory ( for example C:\Users\zhaosong\anaconda3 ).
  7. Give the python interpreter a name ( such as anaconda-python ).
  8. After you install the new python interpreter, you should select it for your eclipse Pydev project.
  9. You can read the article How To Change Python Interpreter In Eclipse Pydev Project To Use Different Python Virtual Environment Library to learn more.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.