Why can’t Python import Image from PIL?

Posted on

Question :

Why can’t Python import Image from PIL?

The single line that I am trying to run is the following:

from PIL import Image

However simple this may seem, it gives an error:

Traceback (most recent call last):
  File "C:...2014-10-22_12-49.py", line 1, in <module>
    from PIL import Image
  File "C:pyzo2014alibsite-packagesPILImage.py", line 29, in <module>
    from PIL import VERSION, PILLOW_VERSION, _plugins
ImportError: cannot import name 'VERSION'

In case that’s helpful, I installed pillow from https://pypi.python.org/pypi/Pillow/2.6.1 (file Pillow-2.6.1.win-amd64-py3.4.exe) before running this (before that there was already som PIL install, which I uninstalled). The script is run in Pyzo with Python version 3.4.1.

What is going wrong, how can I import Image?

Asked By: Betohaku


Answer #1:

I had the same error. Here was my workflow. I first installed PIL (not Pillow) using

pip install --no-index -f https://dist.plone.org/thirdparty/ -U PIL

Then I found Pillow and installed it using

pip install Pillow

What fixed my issues was uninstalling both and reinstalling Pillow

pip uninstall PIL
pip uninstall Pillow
pip install Pillow
Answered By: Trent

Answer #2:

I had the same issue, and did this to fix it:

  1. In command prompt

    pip install Pillow ##
  2. Ensure that you use

    from PIL import Image

I in Image has to be capital. That was the issue in my case.

Answered By: Nijanth Anand

Answer #3:

FWIW, the following worked for me when I had this same error:

pip install --upgrade --force-reinstall pillow
Answered By: overcoded

Answer #4:

If you use Anaconda, you may try:

conda install Pillow


Answered By: Ruikai H

Answer #5:

All the answers were great however what did it for me was a combination of uninstalling Pillow

pip uninstall Pillow

Then installing whatever packages you need e.g.

sudo apt-get -y install python-imaging
sudo apt-get -y install zlib1g-dev
sudo apt-get -y install libjpeg-dev

And then using easy_install to reinstall Pillow

easy_install Pillow

Hope this helps others

Answered By: Omar

Answer #6:

For me, I had typed image with a lower case “i” instead of Image. So I did:

from PIL import Image NOT from PIL import image

Answered By: alkadelik

Answer #7:

The current free version is PIL 1.1.7. This release supports Python 1.5.2 and newer, including 2.5 and 2.6. A version for 3.X will be released later.

Python Imaging Library (PIL)

Your python version is 3.4.1, PIL do not support!

Answered By: selfboot

Answer #8:

In Ubuntu OS, I solved it with the followings commands

pip install Pillow
apt-get install python-imaging

And sorry, dont ask me why, it’s up to me 😉

Answered By: Vivien G.

Leave a Reply

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