MLavrentyev
MLavrentyev

Reputation: 1969

PIL: DLL load failed: specified procedure could not be found

I've been beginning to work with images in Python and I wanted to start using PIL (Pillow). To install it, I ran pip install Pillow. When installing, PIL was not previously installed. I also tried uninstalling it and reinstalling it, as well as using pip3 install Pillow.

When I run it in Python, my first line is:

File "C:\Program Files\Python36\lib\site-packages\PIL\Image.py", line 56, in <module>
from . import _imaging as core
ImportError: DLL load failed: The specified procedure could not be found.

I checked the directory, and the file _imaging.cp36-win_amd64.pyd is present under the PIL folder.

Why is this happening if the needed DLL is there? How can I fix it?

Upvotes: 57

Views: 148283

Answers (16)

John Carter
John Carter

Reputation: 333

For those who are using torch; there seems to be a package mismatch between matplotlib and torchvision, which both require pillow.

How I solved it:

pip uninstall pillow
pip install --force-reinstall pillow

(P.S. I was in a anaconda environment)

Upvotes: 1

AleM
AleM

Reputation: 297

I just updated pillow. it solved the problem!

python -m pip install --upgrade Pillow

Upvotes: 0

halt9k
halt9k

Reputation: 951

Using Procmon or similar tool to check which dll is actually missing may be another way of solving this. Noticed it was libdeflate.dll and seems reinstalling libdeflate (via conda) solved this.

Upvotes: 0

sudarsan N
sudarsan N

Reputation: 1

For people in 2023, for Python 3.10.13, pillow version 10.0.1 worked for me.

Upvotes: 0

Nour Alden
Nour Alden

Reputation: 49

for new people 2022 i solved it you can look at this https://pillow.readthedocs.io/en/latest/installation.html

if PIL don't want to uninstall delete or cut it to another folder

I edits that for people ,who don't read comments:

it depend on your python version , if your python 3.11 ,you can just install pillow >=9.3 if your python version 3.9 ,you can install pillow >=8.3.2 but you can not install pillow 8.3.1 , you need to uninstall it first or move it to another directory

Upvotes: 2

Sarvjeet Bhardwaj
Sarvjeet Bhardwaj

Reputation: 1

I faced the same issue with Python 3.9.12. I uninstalled the pre-installed Pillow version 9.0.1 and simply reinstalled the latest version 9.5.0

$ pip3 uninstall pillow

Found existing installation: pillow 9.0.1
Uninstalling pillow-9.0.1:
  Would remove:
    c:\users\sjitb\anaconda3\lib\site-packages\pil\*
    c:\users\sjitb\anaconda3\lib\site-packages\pillow-9.0.1-py3.9.egg-info
Proceed (Y/n)? y
  Successfully uninstalled pillow-9.0.1
$ pip install pillow

Collecting pillow
  Downloading Pillow-9.5.0-cp39-cp39-win_amd64.whl (2.5 MB)
     |████████████████████████████████| 2.5 MB 2.2 MB/s
Installing collected packages: pillow
Successfully installed pillow-9.5.0

Upvotes: 0

Prabhudsp
Prabhudsp

Reputation: 31

If you are a Windows user and do not have Microsoft Visual C++ the error occurs. I got the same error and resolved this by installing the Microsoft Visual C++. Link for downloading can be found here.

https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0

Upvotes: 0

Akitha Udara
Akitha Udara

Reputation: 1

First uninstall existing version

pip uninstall pillow

Then try installing

pip install pillow==4.0.0

Upvotes: -3

Rohit Gupta
Rohit Gupta

Reputation: 453

Seems like some issue is there with tensorflow 1.12.0 +Python 3.6.0 + win10

Working fine with conda tensorflow.

below steps worked for me for pip tensorflow.

uninstall tensorflow replace your python version with 3.6.1 install latest version of tensorflow(1.13.0)

For installing Tensorflow follow below link:- https://www.tensorflow.org/install/pip

Upvotes: 0

rakidedigama
rakidedigama

Reputation: 794

If you're using Anaconda, try

conda uninstall pillow and then pip install pillow

Came across this issue while working on Caffe2 on Windows 10 (Anaconda 4.5) and this worked for me. Here's the github post on this issue.

Upvotes: 13

Khan
Khan

Reputation: 1498

I had the same problem with anaconda 5.0.1, using it with caffe on windows 10. i just did

conda install PIL

it worked for me.

Upvotes: 0

Hugo
Hugo

Reputation: 29314

There's a problem in Python itself which means binary wheels build using Python 3.6.1 (like Pillow 4.1.0) won't install on Python 3.6.0.

This has affected a number of Python libraries.

However, there's the new Pillow 4.1.1 release works around this, so you can now update to Pillow 4.1.1 and use it with both Python 3.6.0 and 3.6.1.

More info:

Upvotes: 4

dsixnine
dsixnine

Reputation: 111

This works for me using win10 and py 3.6. Simply uninstall Pillow 4.1.0 pip3 uninstall Pillow Then install Pillow 4.0.0 pip3 install Pillow==4.0.0

Upvotes: 0

Joseph Montanaro
Joseph Montanaro

Reputation: 149

This problem is also fixed by upgrading Python to 3.6.1, per this GitHub discussion.

The difference is that Pillow 4.1.0 was built with Python 3.6.1 while Pillow 4.0.0 was built with Python 3.6.0.

Apparently PYTHON36.DLL from Python 3.6.0 is missing functions (PySlice_AdjustIndices and PySlice_Unpack) that are used when building with Python 3.6.1.

The solution is to upgrade to Python 3.6.1.

Upvotes: 4

Ed Bernal
Ed Bernal

Reputation: 319

As in Sean's answer, I had to uninstall (I'm using Anaconda Python 3.6, BTW) with

conda uninstall pillow

I tried it with PIL, but there was no such package. Uninstalling pillow also meant uninstalling packages that depend on it, in my case "anaconda-navigator" and "scikit-image". After I reinstalled Pillow 4.0.0 with

 conda install pillow=4.0.0

and tested it with

python -c "from PIL import Image"

which, if successful, you don't see an error message, I reinstalled the packages that were uninstalled along with Pillow 4.1.0.

conda install anaconda-navigator
conda install scikit-image

Upvotes: 28

Sean
Sean

Reputation: 626

I had this problem as well with Python 3.6. I just avoided the problem by uninstalling pillow (4.1.0) and then installing an older version of pillow (4.0.0). It seems to run okay with the older version.

Upvotes: 58

Related Questions