python編程用到圖像有時(shí)會(huì)出現(xiàn) decoder jpeg not available
那是因?yàn)闆]有裝jpeg編解碼庫或者是python的PIL庫安裝不正確。 出現(xiàn)這種情況最好刪掉PIL庫(進(jìn)入python的site-package目錄,rm -rf PIL PIL.pth),重新再安裝一次。重新安裝步驟如下: 一、安裝jpeg和zlib庫 先用linux發(fā)行版的rpm包安裝jpeg和zlib庫 rpm文件是 libjpeg-devel-6b-37.x86_64.rpm zlib-devel-1.2.3-3.x86_64.rpm 記下安裝到到路徑(庫路徑是/usr/lib64, 頭文件路徑/usr/include) 二、編譯PIL庫 下載并解壓Imaging-1.1.7.tar.gz 進(jìn)入解壓后的目錄,修改setup.py文件把: JPEG_ROOT = None ZLIB_ROOT = None 修改為: JPEG_ROOT = "/usr/lib64", "/usr/include" ZLIB_ROOT = "/usr/lib64", "/usr/include" 運(yùn)行 python setup.py build_ext -i 此命令用第一步的jpeg等庫生成_imaging.so 如果出現(xiàn): -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support available --- ZLIB (PNG/ZIP) support available *** FREETYPE2 support not available *** LITTLECMS support not available -------------------------------------------------------------------- 表示編譯成功。可以運(yùn)行: python selftest.py 驗(yàn)證。正常的話會(huì)出現(xiàn) -------------------------------------------------------------------- *** TKINTER support not installed --- JPEG support ok --- ZLIB (PNG/ZIP) support ok *** FREETYPE2 support not installed *** LITTLECMS support not installed -------------------------------------------------------------------- Running selftest: --- 57 tests passed. 三、安裝與部署 如果上面都正常,運(yùn)行 python setup.py install 會(huì)把PIL模塊放到python的package目錄(如/usr/lib64/python2.4/site-packages/),同時(shí)生成PIL.pth文件
|
|