50

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?

MLavrentyev
  • 1,827
  • 2
  • 24
  • 32

12 Answers12

54

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.

Sean
  • 586
  • 5
  • 8
  • 5
    uninstalling 4.1.0 and doing pip install Pillow==4.0.0 worked for me python 3.6.0, windows 10 – Ted Apr 19 '17 at 17:53
  • 1
    You solved my day! Worked for me in Win10 and python 3.6.0 – edepe Apr 19 '17 at 18:38
  • 1
    Same! It's not normal that going from 4.0.0 to 4.1 breaks everything. There should be some kind of test or whatever to check this. – Olivier Pons Apr 21 '17 at 09:32
  • 3
    Pillow 4.1.1 is now out which you can use for both Python 3.6.0 and 3.6.1. More info: http://stackoverflow.com/a/43723021/724176 – Hugo May 01 '17 at 16:58
  • I have the same problem now with python 3.6.3 and pillow 4.2.1 and 4.3.0. Downgrading to 4.1.1 solves the problem. – Rob Dec 19 '17 at 11:54
26

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
Ed Bernal
  • 299
  • 2
  • 5
  • 3
    This did not work for me. Using Windows 10 and Python 3.5 – Schütze Dec 22 '17 at 14:58
  • 1
    On Win10 with Python 3.5 with conda environment. I desinstalled pillow with conda, reinstalled pillow with pip. And then reinstalled scikit-image with pip and anaconda-navigator with conda (without dependencies install '--no-deps'). – RomaneG Apr 17 '18 at 16:28
  • 1
    Does not work PackagesNotFoundError: The following packages are not available from current channels: - pillow==4.0.0 – Aqua 4 Nov 12 '22 at 10:12
10

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.

rakidedigama
  • 714
  • 7
  • 11
4

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.

  • 1
    Pillow 4.1.1 is now out which you can use for both Python 3.6.0 and 3.6.1. More info: http://stackoverflow.com/a/43723021/724176 – Hugo May 01 '17 at 16:58
  • 1
    Running Python 3.6.4/Win64 `conda install pillow=4.1.1` finally did the trick. No prior uninstall required. – wp78de Mar 15 '18 at 05:54
4

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:

Hugo
  • 27,885
  • 8
  • 82
  • 98
2

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

Nour Alden
  • 29
  • 4
  • 1
    what exactly has to be done there? – Ben Jan 04 '23 at 11:40
  • this answer adds no value. it merely points to official docs that describe installation. – Christoph Rackwitz Feb 06 '23 at 23:35
  • The page says "Pillow >= 2.1.0 no longer supports `import _imaging`. Please use `from PIL.Image import core as _imaging` instead. Perhaps that's what's required. – S Anand Mar 12 '23 at 00:03
  • 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 – Nour Alden Apr 28 '23 at 17:16
0

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

dsixnine
  • 101
  • 1
  • 5
0

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.

Khan
  • 1,288
  • 12
  • 11
0

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

Rohit Gupta
  • 443
  • 3
  • 17
0

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

Prabhudsp
  • 31
  • 1
0

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
Mohnish
  • 1,010
  • 1
  • 12
  • 20
-2

First uninstall existing version

pip uninstall pillow

Then try installing

pip install pillow==4.0.0
Michael Szczesny
  • 4,911
  • 5
  • 15
  • 32
  • 3
    What is the point to post same answer as the accepted one after 3.5 years? (and some other include this info as well) – Ruli Oct 04 '20 at 08:19