Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install PIL fails

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.

like image 888
user3831214 Avatar asked Sep 24 '15 23:09

user3831214


People also ask

How do I fix No module named PIL in Python?

The Python "ModuleNotFoundError: No module named 'PIL'" occurs when we forget to install the Pillow module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install Pillow command.

Why can't I install using pip?

This error usually means there's a problem with the Python installation or the system variable PATH is not set up correctly. Try reinstalling Python and all its components to fix the problem. The easiest way is via the Python executable installer.

Is PIL a package in Python?

Python Imaging Library (expansion of PIL) is the de facto image processing package for Python language. It incorporates lightweight image processing tools that aids in editing, creating and saving images.


2 Answers

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.

like image 92
Hugo Avatar answered Oct 13 '22 00:10

Hugo


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

pip install Pillow 

To import use following:

from PIL import Image 
like image 37
Rish Avatar answered Oct 13 '22 01:10

Rish