How To Fix The Python Pillow Error ImportError: DLL load failed while importing _imaging: The specified module could not be found.

When I use LiClipse ( Eclipse plus PyDev plugin ) to develop & run a Python pillow project, I meet the following error message ImportError: DLL load failed while importing _imaging: The specified module could not be found. This article will tell you how to fix it.

1. My Environment That Trigger The ImportError: DLL load failed while importing _imaging: The specified module could not be found.

  1. This error happened on both Windows 10 & Windows 7.
  2. I use anaconda 3 as my eclipse Pydev project python interpreter.
  3. The pillow version is 8.2.0, I run the command pip show pillow to get the version.
    (base) C:\Users\Jerry>pip show pillow
    Name: Pillow
    Version: 8.2.0
    Summary: Python Imaging Library (Fork)
    Home-page: https://python-pillow.org
    Author: Alex Clark (PIL Fork Author)
    Author-email: [email protected]
    License: HPND
    Location: c:\users\jerry\anaconda3\lib\site-packages
    Requires:
    Required-by: scikit-image, matplotlib, imageio, bokeh
  4. And my python version is 3.8.8. From the pillow official page, it said the python version should >= 3.6, so I think the python version is ok.
  5. I use LiClipse which is an Eclipse integrated with PyDev plugin to run some pillow source code, and this error also happened when I run the pillow source code in Eclipse + Pydev plugin.
  6. Below is the detailed error message.
    Traceback (most recent call last):
      File "D:\Work\dev2qa.com-example-code\PythonExampleProject\com\dev2qa\example\code_learner_dot_com_example\pillow_example.py", line 8, in <module>
        from PIL import Image
      File "C:\Users\Jerry\anaconda3\Lib\site-packages\PIL\Image.py", line 109, in <module>
        from . import _imaging as core
    ImportError: DLL load failed while importing _imaging: The specified module could not be found.

2. How To Fix The ImportError: DLL load failed while importing _imaging: The specified module could not be found.

  1. To fix this error is also easy, the error is because the pillow version is too new.
  2. First, uninstall the current pillow version with the command pip uninstall pillow.
    (base) C:\Users\Jerry>pip uninstall pillow
    Found existing installation: Pillow 8.2.0
    Uninstalling Pillow-8.2.0:
      Would remove:
        c:\users\jerry\anaconda3\lib\site-packages\pil\*
        c:\users\jerry\anaconda3\lib\site-packages\pillow-8.2.0.dist-info\*
    Proceed (y/n)? y
      Successfully uninstalled Pillow-8.2.0
  3. Run the command pip show pillow to confirm that the pillow has been uninstalled successfully.
    (base) C:\Users\Jerry>pip show pillow
    WARNING: Package(s) not found: pillow
  4. Go to the pillow official release site to get a release version that maybe match your environments, I select version 8.0.0.
  5. Run the command pip install pillow==8.0.0 to install the pillow version 8.0.0.
    (base) C:\Users\Jerry>pip install pillow==8.0.0
    Collecting pillow==8.0.0
      Downloading Pillow-8.0.0-cp38-cp38-win_amd64.whl (2.1 MB)
         |████████████████████████████████| 2.1 MB 345 kB/s
    Installing collected packages: pillow
    Successfully installed pillow-8.0.0
  6. Run the command pip show pillow to confirm the pillow 8.0.0 version has been installed successfully.
    (base) C:\Users\Jerry>pip show pillow
    Name: Pillow
    Version: 8.0.0
    Summary: Python Imaging Library (Fork)
    Home-page: https://python-pillow.org
    Author: Alex Clark (PIL Fork Author)
    Author-email: [email protected]
    License: HPND
    Location: c:\users\jerry\anaconda3\lib\site-packages
    Requires:
    Required-by: scikit-image, matplotlib, imageio, bokeh
  7. Restart the LiClipse or Eclipse, and now the error will be fixed.

References

  1. How To Change Python Interpreter In Eclipse Pydev Project To Use Different Python Virtual Environment Library.

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.