pip install PIL fails

PythonDjangoPipPython Imaging-Library

Python Problem Overview


I am trying to install the pip package PIL. However the install doesn't work throwing the following error.

Could not find a version that satisfies the requirement pil (from xhtml2pdf==0.0.4->-r virtualenv-reqs.txt (line 16)) (from versions: )
  Some externally hosted files were ignored as access to them may be unreliable (use --allow-external pil to allow).
No matching distribution found for pil (from xhtml2pdf==0.0.4->-r virtualenv-reqs.txt (line 16))

The install does work when I have an older version of pip, but with the current version of pip 7.1.2 I am not able to download the package. I am using the following command to install the pip packages

pip install --timeout=1000 -i http://pypi.ksjc.sh.colo/simple --trusted-host pypi.ksjc.sh.colo -r virtualenv-reqs.txt

What is the issue with this. I thought it might be an SSL issue which is why I added the --trusted-host flag. Is there any way to the --allow-external flag to be used with the virtualenv-reqs file.

Python Solutions


Solution 1 - Python

Pillow is a maintained fork of PIL, so I recommend using Pillow. But you can't have both installed at the same time.

  1. First, remove both PIL and Pillow.

  2. Then install Pillow with pip install pillow (although, depending on platform, you may need some prerequisites).

  3. Then make sure code is using from PIL import Image rather than import Image.

Solution 2 - Python

You can try using Pillow instead, which is a PIL fork:

pip install Pillow

To import use following:

from PIL import Image

Solution 3 - Python

One solution that worked for me:

By simply installing the latest version of Pillow using pip install -U Pillow I can now call import PIL.Image

Solution 4 - Python

One solution was, right-click on 'from PIL import Image' and click 'install Image'

I was on the PyCharm IDE.

Solution 5 - Python

I'm using PyCharm IDE, and I had this problem. I simply hovered my mouse to the 'PIL' and there's a small pop-up. I clicked more actions and several options appear. I clicked 'Install Pillow, and then, problem solved.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3831214View Question on Stackoverflow
Solution 1 - PythonHugoView Answer on Stackoverflow
Solution 2 - PythonRishView Answer on Stackoverflow
Solution 3 - PythonBAKYACView Answer on Stackoverflow
Solution 4 - PythonJose GarzaView Answer on Stackoverflow
Solution 5 - PythonLambert HoltlandView Answer on Stackoverflow