我對開發相對比較陌生,我一直試圖在Django(在Windows 7,64位)上構建一個應用程序來接受通過ImageField上傳的圖像。我最初安裝了PIL,但發現我首先需要JPEG和PNG庫。所以我使用「pip uninstall pil」卸載了PIL,並在C:\ zlib-1.2.7 \ zlib.lib和C:\ jpeg-8d \ libjpeg.lib中設置了這些庫。後來,我走進在PIL的setup.py,改變了以下情況:JPEG和PNG庫在PIL中使用
JPEG_ROOT = "C:/jpeg-8d"
ZLIB_ROOT = "C:/zlib-1.2.7"
然後我安裝通過:
pip install C:\Imaging-1.1.7\
我在安裝結束,這表明有JPEG以下和PNG支持:
:Installing collected packages: PIL
Running setup.py install for PIL
WARNING: '' not a valid package name; please use only.-separated package nam
es in setup.py
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform win32 2.6.6 (r266:84297, Aug 24 2010, 18:46:32)
[MSC v.1500 32 bit (Intel)]
--------------------------------------------------------------------
*** TKINTER support not available (Tcl/Tk 8.5 libraries needed)
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
To check the build, run the selftest.py script.
Successfully installed PIL
Cleaning up...
但是,我得到selftest.py,這表明不支持測試以下時
C:\Windows\system32>python C:\Imaging-1.1.7\selftest.py
--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from C:\Users\ayan\Desktop\Imaging-1.1.7\PIL
Binary modules loaded from C:\Python26_x86\lib\site-packages\PIL
--------------------------------------------------------------------
*** PIL CORE support not installed
*** TKINTER support not installed
*** JPEG support not installed
*** ZLIB (PNG/ZIP) support not installed
*** FREETYPE2 support not installed
*** LITTLECMS support not installed
--------------------------------------------------------------------
我也試過用JPEG工作,並得到了以下IO錯誤:
C:\Users\Public\Pictures\Sample Pictures>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>> import os, sys
>>> import Image
>>> img = Image.open(Desert.jpg)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Desert' is not defined
>>> img = Image.open("Desert.jpg")
>>> img.save("Desert_test.jpg")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26_x86\lib\site-packages\PIL\Image.py", line 1406, in save
self.load()
File "C:\Python26_x86\lib\site-packages\PIL\ImageFile.py", line 189, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "C:\Python26_x86\lib\site-packages\PIL\Image.py", line 385, in _getdecode
r
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available
這有點類似於報道在https://stackoverflow.com/questions/10543581/pil-installation-run-issue;然而,看起來在這種情況下,JPEG實際上不起作用。 PNG觀察到類似的問題。
我不清楚在這個過程中我犯了什麼錯誤,所以任何意見將不勝感激。請讓我知道如果需要額外的信息,我會盡力做到最好。
非常感謝。