在Mac OS系統(tǒng)上安裝Python的Pillow庫的教程
今天幫朋友做個python的小工具,發(fā)現(xiàn)系統(tǒng)上缺少ptyhon的支持庫,返回如下信息
ImportError: No module named PIL
然后就下載安裝,因為機(jī)器上也沒有python的管理工具pip,所以也一并安裝
1. 安裝pip
sudo easy_install pip
pip 安裝成功就可以直接安裝pil或者pillow
2. 通過命令pip install pil
pip install Pil
Downloading/unpacking Pil Could not find any downloads that satisfy the requirement Pil Some externally hosted files were ignored (use --allow-external Pil to allow). Cleaning up... No distributions at all found for Pil Storing debug log for failure in /Users/macbook/Library/Logs/pip.log
3. 所以就安裝pillow
pip install --use-wheel Pillow
Downloading/unpacking Pillow Downloading Pillow-2.4.0.zip (6.5MB): 5.0MB downloaded Cleaning up...
弄了會別的回來發(fā)現(xiàn)還沒有下載完,這叫一個慢呀,于是放棄
4. Git
通過git下載源碼地址https://github.com/python-imaging/Pillow
git clone https://github.com/python-imaging/Pillow.git
然后開始編譯安裝
4.1
python setup.py build_ext -i
編譯完之后會提示運(yùn)行測試?yán)樱⑶野l(fā)現(xiàn)JPEG support not available
--------------------------------------------------------------------
version Pillow 2.4.0
platform darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX 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.
4.2 因為JPEG support not available,運(yùn)行python selftest.py報告錯誤
1 tests of 57 failed.
于是只好卸載pillow
可以通過pip命令來卸載
pip uninstall pillow sudo pip uninstall pillow
Password: Uninstalling Pillow: /Library/Python/2.7/site-packages/Pillow-2.4.0-py2.7-macosx-10.9-intel.egg /usr/local/bin/pilconvert.py /usr/local/bin/pildriver.py /usr/local/bin/pilfile.py /usr/local/bin/pilfont.py /usr/local/bin/pilprint.py Proceed (y/n)? y
Successfully uninstalled Pillow
成功之后需要安裝libjpeg的支持
brew install libjpeg
安裝成功之后重新編譯pillow
--------------------------------------------------------------------
version Pillow 2.4.0
platform darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------
python selftest.py
--------------------------------------------------------------------
Pillow 2.4.0 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL
Binary modules loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
--- JPEG support ok
*** JPEG 2000 support not installed
--- ZLIB (PNG/ZIP) support ok
*** LIBTIFF support not installed
--- FREETYPE2 support ok
*** LITTLECMS2 support not installed
*** WEBP support not installed
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.
最后執(zhí)行安裝
sudo python setup.py install
相關(guān)文章
python實現(xiàn)替換word中的關(guān)鍵文字(使用通配符)
今天小編就為大家分享一篇python實現(xiàn)替換word中的關(guān)鍵文字(使用通配符),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-02-02
Python用zip函數(shù)同時遍歷多個迭代器示例詳解
這篇文章主要給大家進(jìn)行介紹了Python如何用zip函數(shù)同時遍歷多個迭代器,文中給出了示例以及原理和注意事項,相信會對大家的理解和學(xué)習(xí)很有幫助,有需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧。2016-11-11
人臉檢測實戰(zhàn)終極之OpenCV+Python實現(xiàn)人臉對齊
這篇文章主要是為了演示如何使用 OpenCV、Python 和面部標(biāo)志從而實現(xiàn)對齊人臉。文中示例代碼對我們的工作或?qū)W習(xí)有一定的幫助,感興趣的小伙伴可以學(xué)習(xí)一下2021-12-12
關(guān)于ResNeXt網(wǎng)絡(luò)的pytorch實現(xiàn)
今天小編就為大家分享一篇關(guān)于ResNeXt網(wǎng)絡(luò)的pytorch實現(xiàn),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-01-01
解決TensorFlow訓(xùn)練內(nèi)存不斷增長,進(jìn)程被殺死問題
今天小編就為大家分享一篇解決TensorFlow訓(xùn)練內(nèi)存不斷增長,進(jìn)程被殺死問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-02-02

