To help new colleagues deploy the development environment, because the project code used in the PIL library processing pictures, resulting in some pictures in the browser can not display properly.
Several toss, solve the problem, here to record the issue of the newspaper, and Solutions:
1. Python version is not correct, 64-bit Python can not be installed, and can not be installed on the 32-bit PIL, so first change the PY to 32-bit version, this is the first to understand. No objection.
2. After installing PIL official compiled package, it will take place that the famous: the _IMAGINGFT C module is not installed, it is better to re-next at this time:
Address in http://www.lfd.uci.edu/~gohlke/pythonlibs/
Here are some third-party organizations compiled EXE package, to download the corresponding PY version of the PIL, re-install, it is best to download pillow, it is the PIL of some bug fixes after the compiled version
Before installing, you can first pip uninstall PiL
3. After installing the pillow, keyerror error may also occur, check the project source after the discovery is the image module of the Save function, processing picture file format times of the wrong.
Whether it's "JPEG" or "GIF", it will be an error, the solution is:
The project source in the import image, replaced by the from PIL import image.
According to this principle, all areas of the project that use the Image module should be replaced.
In addition, the Save Dictionary of the image can be tested in the CMD console,
>>> Import Image
>>> Image.init ()
1
>>> Image.SAVE.keys ()
[' XBM ', ' PCX ', ' SPIDER ', ' HDF5 ', ' TIFF ', ' BUFR ', ' EPS ', ' JPEG ', ' MSP ', ' GRIB ', '
GIF ', ' BMP ', ' TGA ', ' IM ', ' PPM ', ' PDF ', ' FITS ', ' PALM ', ' WMF ', ' PNG '
After the above test, if the Image.SAVE.keys () output is empty, then the SAVE format key is not found, and when the image is generated it will be reported Keyerror, the first line must be changed to: from PIL import Image
Transfer from old version PiL to Pillow