Pillow: Conda: Pillow DLL error when loading Image

Created on 10 Jan 2018  路  46Comments  路  Source: python-pillow/Pillow

What did you do?

I upgraded pillow to 5.0.0 and python to 3.6.30h3b118a2_4 using anaconda prompt.
Then i tried...
from PIL import Image

What did you expect to happen?

I expected that the library would load.

What actually happened?

Instead I keep getting this error...
from PIL import Image
Traceback (most recent call last):

File "", line 1, in
from PIL import Image

File "C:\Usersbendo\Anaconda3\lib\site-packages\PIL\Image.py", line 58, in
from . import _imaging as core

ImportError: DLL load failed: The specified module could not be found.

What versions of Pillow and Python are you using?

Using pillow-5.0.0
and using python-3.6.30h3b118a2_4

Installation Windows

Most helpful comment

@hugovk conda uninstall pillow and then pip install pillow work for me.Thank!

All 46 comments

I also cloned this GIT file to a folder and tried to call Image manually. I see that the _imaging file is a c type. is there any special way to deal with this or should it work?

so far I have tried pillow versions 4.2.1 onward and none work.

You need to build the C files or, best on Windows, install a wheel.

Which version of Windows are you on?

Please can you paste the output of installing Pillow?

im using windows 10, and im re-installing Anaconda right now but the code i used is "conda install pillow=5.0.0"

Same problem here, did you found the solution?

Please can you paste the output of installing Pillow?

Or how about with 'pip install pillow' (maybe uninstall the conda one first)?

So very odd, I reinstalled anaconda and it worked, but after not immediately after, though after, downloading opencv I got the same PIL error as well as import cv2 stopped working. I'm starting to think it's an anaconda problem.

@hugovk conda uninstall pillow and then pip install pillow work for me.Thank!

Good to hear.

Looks like conda don't have a Pillow 5.0.0 thing ready, see https://github.com/conda-forge/pillow-feedstock/pull/41.

https://github.com/conda-forge/pillow-feedstock/pull/41 was replaced by https://github.com/conda-forge/pillow-feedstock/pull/43 which has been merged so I guess conda install should also work now or soon.

Same here, I am using Anaconda Spyder 3.2.4, on Python 3.6.3, Pillow 5.0.0

I installed Pillow using "conda install -c anaconda pillow"
While using "from PIL import Image"
Facing the error :- "ImportError: DLL load failed: The specified module could not be found."

Trying various forums, reading various documents since last 2/3 days. But still the same error. Its painful. I don't know how to resolve it.

Can you help ?

Until conda is updated, try conda uninstall pillow and then pip install pillow instead.

To try the conda-forge version one can use the command:

conda install --channel conda-forge pillow=5

Ideally one should have the conda-forge channel on the .condarc and be aware of channel incompatibilities!

  1. I uninstalled Anaconda.
  2. Uninstalled Python. (Cleaned everything)
  3. Installed Python 3.6.0
  4. Installed Spyder (using: pip install spyder)
  5. Installed numpy, pillow etc (using: pip install pillow--log log.txt)
  6. This successfully installed pillow-5.0.0
    Cleaning up...(last line of log)
  7. When I use import matplotlib.image as mpimg , it executes good
  8. But when I use from PIL import image I still get a error,
    Error:--
    from PIL import image

ImportError: cannot import name 'image'

This is really a pain. Can some one please tell me how to solve this ?

pillow_log.txt

I have attached the Pillow 5.0.0 installation log file.
In the "/Lib/site-packages" folder I find only the "/Pillow-5.0.0.dist-info" folder. There is no "/Pillow" folder that I can find.

Can some one please tell me , what I am missing ?

@TanayAarush It's case sensitive. Instead of from PIL import image do from PIL import Image

The same issue, Python 3.6.4 Anaconda, Windows 10

Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Anaconda3\lib\site-packages\PIL\Image.py", line 58, in <module>
    from . import _imaging as core
ImportError: DLL load failed: The specified module could not be found.

i am using Anaconda 3.6.3 and i installed opencv and was working fine but later tried to install tesseract and it threw error and i changed my pillow version to 4.0.0 and now there is an error with opencv . Any suggestion ??

Error:python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.
900 64 bit (AMD64)] on win32
ype "help", "copyright", "credits" or "license" for more information.
>> import cv2
raceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "C:\ProgramData\Anaconda3\lib\site-packages\cv2\__init__.py", line 4, in
module>

I also have this issue. Python 3.6 in Spyder on Windows. Re-installations also did not fix the issue for me. pip install pillow also did not solve it.

Manual installation of pillow gave me this error:
ImportError: The _imaging extension was built for another version of Pillow or PIL:
Core version: 5.0.0
Pillow version: 4.2.1

@Metamorphus Pillow refuses to run if there is a mismatch between the version of the python part and the core c part. You either have 2 different versions installed, or you've manually installed version 5 of the dll and version 4.2 of the python.

Remove them all, and reinstall the one version you want.

@wiredfool Thanks, installation of 4.2.1 version from conda-forge channel helped. Installation from conda default channel gave "DLL load failed" error for the line "from PIL import Image".

Same issue. Windows 10, Latest conda on Windows. Python 3
Nothing of the above helps.

Do a conda update conda, then try the same.
Using Python 3.6.4 + Win10 on Anaconda 5.1

I removed the conda version, currently using pip install Pillow instead.

Same. Uninstalling Pillow from Conda and using Pip to install Pillow is what worked for me.

Uninstalling Pillow using conda, then using pip to install Pillow worked for me.

Looks like this is really a problem with conda and there's a fix (use pip), so I'll close this. Please open an issue with conda and add a link.

I fixed this by simply upgrading all packages: conda update --all

Posting this answer from stackoverflow which worked for me

~> This is a problem in python 3.6 Edit file: C:\Anaconda\lib\site-packages\PIL\Image.py and change code: if PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None): raise ImportError("The _imaging extension was built for another " " version of Pillow or PIL")~

~> change that to: if core.PILLOW_VERSION != getattr(core, 'PILLOW_VERSION', None): raise ImportError("The _imaging extension was built for another " " version of Pillow or PIL")~

~> This will solve the problem. Regards ~

--by this guy ---> https://stackoverflow.com/users/7578651/ibrahim

edit: removed dangerous advice

Umm. No. Don't do that.

@hugovk Do you have enough points on stack overflow to explain why this is a bad idea? I can't comment there.

Commented and downvoted.

thanks @hugovk

thanks @hugovk . Your suggestion worked for me.

I had the same issue and uninstalling pillow and re-installing with pip helped

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\WINDOWS\system32>**conda remove pillow**
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.4.10
  latest version: 4.5.4

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: D:\Python\Anaconda3

  removed specs:
    - pillow


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2018.4.16          |           py36_0         143 KB
    ca-certificates-2018.03.07 |                0         155 KB
    openssl-1.0.2o             |       h8ea7d77_0         5.4 MB
    ------------------------------------------------------------
                                           Total:         5.7 MB

The following packages will be REMOVED:

    anaconda-navigator: 1.7.0-py36_0
    pillow:             5.0.0-py36h0738816_0
    scikit-image:       0.13.1-py36hfa6e2cd_1
    **wordcloud**:          1.4.1-py36_0          conda-forge

The following packages will be UPDATED:

    certifi:            2018.4.16-py36_0      conda-forge --> 2018.4.16-py36_0
    openssl:            1.0.2o-vc14_0         conda-forge [vc14] --> 1.0.2o-h8ea
7d77_0

The following packages will be DOWNGRADED:

    ca-certificates:    2018.4.16-0           conda-forge --> 2018.03.07-0

Proceed ([y]/n)? y


Downloading and Extracting Packages
certifi 2018.4.16: #################################################### | 100%
ca-certificates 2018.03.07: ########################################### | 100%
openssl 1.0.2o: ####################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: - DEBUG menuinst_win32:__init__(199): Menu: name: 'Anacon
da${PY_VER} ${PLATFORM}', prefix: 'D:\Python\Anaconda3', env_name: 'None', mode:
 'None', used_mode: 'system'
**DEBUG menuinst_win32:create(323): Shortcut cmd is D:\Python\Anaconda3\pythonw.ex
e, args are ['D:\\Python\\Anaconda3\\cwp.py', 'D:\\Python\\Anaconda3', 'D:\\Pyth
on\\Anaconda3\\pythonw.exe', 'D:\\Python\\Anaconda3\\Scripts\\anaconda-navigator
-script.py**']
done

C:\WINDOWS\system32>pip install pillow
Collecting pillow
  Downloading https://files.pythonhosted.org/packages/a4/86/283719dac6309cf48345
2abb09759be9b2c0974435ed608dc67949127e13/Pillow-5.1.0-cp36-cp36m-win_amd64.whl (
1.6MB)
    100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 1.6MB 596kB/s
Installing collected packages: pillow
Successfully installed pillow-5.1.0
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.

C:\WINDOWS\system32>**conda install -c conda-forge wordcloud**
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.4.10
  latest version: 4.5.4

Please update conda by running

    $ conda update -n base conda



## Package Plan ##

  environment location: D:\Python\Anaconda3

  added / updated specs:
    - wordcloud


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2018.4.16          |           py36_0         143 KB  conda-forge
    pillow-5.1.0               |           py36_0         766 KB  conda-forge
    ------------------------------------------------------------
                                           Total:         909 KB

The following NEW packages will be INSTALLED:

    pillow:          5.1.0-py36_0      conda-forge
    wordcloud:       1.4.1-py36_0      conda-forge

The following packages will be UPDATED:

    ca-certificates: 2018.03.07-0                  --> 2018.4.16-0      conda-fo
rge
    certifi:         2018.4.16-py36_0              --> 2018.4.16-py36_0 conda-fo
rge
    openssl:         1.0.2o-h8ea7d77_0             --> 1.0.2o-vc14_0    conda-fo
rge [vc14]

Proceed ([y]/n)? y


Downloading and Extracting Packages
certifi 2018.4.16: #################################################### | 100%
pillow 5.1.0: ######################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

C:\WINDOWS\system32>

I am using spyder and closing spyder and opening it again - no more issue with wordcloud import

If anyone can reproduce this and would like to help conda fix it, please go to:

https://github.com/conda-forge/pillow-feedstock/issues/45

and try:

https://github.com/conda-forge/pillow-feedstock/issues/45#issuecomment-383955861

For what it's worth, I had this same issue. I followed almost the entire thread and tried everything on here, but nothing was working. Then another notebook I had training a model was starting to steal up my memory so I re-started/cleared the notebook that was having the issue with PIL (as a dependency on wordcloud). Something I did before re-starting the notebook did the trick, but I am not sure if it was the re-start or what. Seems like a strange issue.

I updated to pillow 5.2 (using conda update) and the problem went away. Image.py is obviously different now.

Looks like there's a proposed fix in Conda at https://github.com/conda/conda/issues/7626 that you can test out.

windows10 conda2 use conda install --channel conda-forge pillow=5.2.0 install pillow 5.2.0,fix this problem

We have got to this issue too. Default install of pillow runs into the DLL Problem on windows 64 for 5.3.0 too.

Fix manually byconda install --channel conda-forge pillow=5

How can I force this package becomes installed from conda-forge without changing the search order?

I just had the same problem. I have no idea why it happens.
so I do some try and found a solution: my old pillow version is 5.1.0, and it worked well, so I just want to keep this version and tried with:

conda install pillow==5.1.0

following info from my conda console:

Solving environment: done

Package Plan

environment location: C:\Anaconda3

added / updated specs:
- pillow==5.1.0

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
sqlite-3.25.2              |    hfa6e2cd_1000         974 KB  conda-forge
zlib-1.2.11                |    h2fa13f4_1003         236 KB  conda-forge
libsodium-1.0.16           |    h2fa13f4_1001         582 KB  conda-forge
krb5-1.16.1                |    h038dc86_1000         825 KB  conda-forge
blosc-1.14.4               |    h6538335_1000         1.7 MB  conda-forge
pywin32-ctypes-0.2.0       |        py36_1000          35 KB  conda-forge
libiconv-1.15              |    hfa6e2cd_1003         678 KB  conda-forge
hdf5-1.10.2                |       he51fdeb_2        34.8 MB  conda-forge
pillow-5.1.0               |           py36_0         766 KB  conda-forge
libtiff-4.0.9              |    h36446d0_1002         828 KB  conda-forge
libxml2-2.9.8              |    h9ce36c8_1005         3.2 MB  conda-forge
libxslt-1.1.32             |    heafd4d3_1002         457 KB  conda-forge
icu-58.2                   |       ha66f8fd_1        21.9 MB  anaconda
curl-7.60.0                |       h7602738_0         120 KB  anaconda
jpeg-9c                    |    hfa6e2cd_1001         314 KB  conda-forge
qt-5.9.6                   |   vc14h1e9a669_2        93.9 MB
lzo-2.10                   |       h6df0209_2         154 KB  anaconda
libpng-1.6.35              |    h7602738_1002         1.3 MB  conda-forge
zeromq-4.2.5               |    he025d50_1006         9.6 MB  conda-forge
yaml-0.1.7                 |    hfa6e2cd_1001         221 KB  conda-forge
freetype-2.8.1             |       ha63716d_1         468 KB  conda-forge
pyinstaller-3.4            |   py36h7602738_0         2.6 MB  conda-forge
bzip2-1.0.6                |    hfa6e2cd_1002         144 KB  conda-forge
tk-8.6.8                   |    hfa6e2cd_1000         3.8 MB  conda-forge
snappy-1.1.7               |    h6538335_1002          80 KB  conda-forge
libssh2-1.8.0              |    hc4dcbb0_1002         184 KB  conda-forge
------------------------------------------------------------
                                       Total:       179.8 MB

The following NEW packages will be INSTALLED:

pywin32-ctypes: 0.2.0-py36_1000      conda-forge

The following packages will be UPDATED:

blosc:          1.7.0-vc14_2         anaconda    [vc14] --> 1.14.4-h6538335_1000 conda-forge
bzip2:          1.0.6-vc14_1         conda-forge [vc14] --> 1.0.6-hfa6e2cd_1002  conda-forge
curl:           7.60.0-vc14_0        conda-forge [vc14] --> 7.60.0-h7602738_0    anaconda
freetype:       2.8.1-vc14_0         conda-forge [vc14] --> 2.8.1-ha63716d_1     conda-forge
hdf5:           1.10.2-vc14_0        conda-forge [vc14] --> 1.10.2-he51fdeb_2    conda-forge
icu:            58.2-vc14_0          conda-forge [vc14] --> 58.2-ha66f8fd_1      anaconda
jpeg:           9b-vc14_2            conda-forge [vc14] --> 9c-hfa6e2cd_1001     conda-forge
krb5:           1.14.6-vc14_0        conda-forge [vc14] --> 1.16.1-h038dc86_1000 conda-forge
libiconv:       1.15-vc14h29686d3_5  anaconda    [vc14] --> 1.15-hfa6e2cd_1003   conda-forge
libpng:         1.6.34-vc14_0        conda-forge [vc14] --> 1.6.35-h7602738_1002 conda-forge
libsodium:      1.0.16-vc14_0        conda-forge [vc14] --> 1.0.16-h2fa13f4_1001 conda-forge
libssh2:        1.8.0-vc14hcf584a9_2 anaconda    [vc14] --> 1.8.0-hc4dcbb0_1002  conda-forge
libtiff:        4.0.9-vc14_0         conda-forge [vc14] --> 4.0.9-h36446d0_1002  conda-forge
libxml2:        2.9.7-vc14_0         conda-forge [vc14] --> 2.9.8-h9ce36c8_1005  conda-forge
libxslt:        1.1.32-vc14_0        conda-forge [vc14] --> 1.1.32-heafd4d3_1002 conda-forge
lzo:            2.10-vc14_0          conda-forge [vc14] --> 2.10-h6df0209_2      anaconda
pillow:         5.1.0-py36h0738816_0             --> 5.1.0-py36_0         conda-forge
pyinstaller:    3.3.1-py36_vc14_0    conda-forge [vc14] --> 3.4-py36h7602738_0   conda-forge
qt:             5.9.4-vc14hd9fb3db_0 anaconda    [vc14] --> 5.9.6-vc14h1e9a669_2
snappy:         1.1.7-vc14_1         conda-forge [vc14] --> 1.1.7-h6538335_1002  conda-forge
sqlite:         3.22.0-vc14_0        conda-forge [vc14] --> 3.25.2-hfa6e2cd_1000 conda-forge
tk:             8.6.8-vc14_0         conda-forge [vc14] --> 8.6.8-hfa6e2cd_1000  conda-forge
vc:             14-h0510ff6_3                    --> 14.1-h21ff451_3      anaconda
vs2015_runtime: 14.0.25123-3                     --> 15.5.2-3             anaconda
yaml:           0.1.7-vc14_0         conda-forge [vc14] --> 0.1.7-hfa6e2cd_1001  conda-forge
zeromq:         4.2.5-vc14_2         conda-forge [vc14] --> 4.2.5-he025d50_1006  conda-forge
zlib:           1.2.11-vc14_0        conda-forge [vc14] --> 1.2.11-h2fa13f4_1003 conda-forge

Proceed ([y]/n)? y

Downloading and Extracting Packages
sqlite-3.25.2 | 974 KB | ############################################################################ | 100%
zlib-1.2.11 | 236 KB | ############################################################################ | 100%
libsodium-1.0.16 | 582 KB | ############################################################################ | 100%
krb5-1.16.1 | 825 KB | ############################################################################ | 100%
blosc-1.14.4 | 1.7 MB | ############################################################################ | 100%
pywin32-ctypes-0.2.0 | 35 KB | ############################################################################ | 100%
libiconv-1.15 | 678 KB | ############################################################################ | 100%
hdf5-1.10.2 | 34.8 MB | ############################################################################ | 100%
pillow-5.1.0 | 766 KB | ############################################################################ | 100%
libtiff-4.0.9 | 828 KB | ############################################################################ | 100%
libxml2-2.9.8 | 3.2 MB | ############################################################################ | 100%
libxslt-1.1.32 | 457 KB | ############################################################################ | 100%
icu-58.2 | 21.9 MB | ############################################################################ | 100%
curl-7.60.0 | 120 KB | ############################################################################ | 100%
jpeg-9c | 314 KB | ############################################################################ | 100%
qt-5.9.6 | 93.9 MB | ############################################################################ | 100%
lzo-2.10 | 154 KB | ############################################################################ | 100%
libpng-1.6.35 | 1.3 MB | ############################################################################ | 100%
zeromq-4.2.5 | 9.6 MB | ############################################################################ | 100%
yaml-0.1.7 | 221 KB | ############################################################################ | 100%
freetype-2.8.1 | 468 KB | ############################################################################ | 100%
pyinstaller-3.4 | 2.6 MB | ############################################################################ | 100%
bzip2-1.0.6 | 144 KB | ############################################################################ | 100%
tk-8.6.8 | 3.8 MB | ############################################################################ | 100%
snappy-1.1.7 | 80 KB | ############################################################################ | 100%
libssh2-1.8.0 | 184 KB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done


after this update, i noticed and i think the most important is new package:
"The following NEW packages will be INSTALLED:
pywin32-ctypes: 0.2.0-py36_1000 conda-forge"

now, problem is solved! Hope this can help you guys.
(why it worked before without " pywin32-ctypes: 0.2.0-py36_1000", I dont know)

Windows 10 + conda 4.5.11
I had to install Pillow 4.1.1 through pip (powershell) to make it work.
conda list here
pillow5.2.0 py36h08bbbbd_0 is still there.

windows10 conda2 use conda install --channel conda-forge pillow=5.2.0 install pillow 5.2.0,fix this problem

Yes! Fixed it for me as well.

Windows 10
Python 3.7.1

What did you do?

I upgraded pillow to 5.0.0 and python to 3.6.30h3b118a2_4 using anaconda prompt.
Then i tried...
from PIL import Image

What did you expect to happen?

I expected that the library would load.

What actually happened?

Instead I keep getting this error...
from PIL import Image
Traceback (most recent call last):

File "", line 1, in
from PIL import Image

File "C:\Usersbendo\Anaconda3\lib\site-packages\PIL\Image.py", line 58, in
from . import _imaging as core

ImportError: DLL load failed: The specified module could not be found.

What versions of Pillow and Python are you using?

Using pillow-5.0.0
and using python-3.6.30h3b118a2_4

i have tried this and worked well
conda install -c anaconda pillow
after that write this code and execute it
from PIL import Image

@hugovk conda uninstall pillow and then pip install pillow work for me.Thank!

Worked for me, Thanks.

win 10, python 3.7.6, pillow 7.0.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

damianmoore picture damianmoore  路  4Comments

hxzhao527 picture hxzhao527  路  4Comments

HansHirse picture HansHirse  路  3Comments

naaaargle picture naaaargle  路  3Comments

FlowerCode picture FlowerCode  路  4Comments