在Mac OS系統(tǒng)上安裝Python的Pillow庫(kù)的教程
今天幫朋友做個(gè)python的小工具,發(fā)現(xiàn)系統(tǒng)上缺少ptyhon的支持庫(kù),返回如下信息
ImportError: No module named PIL
然后就下載安裝,因?yàn)闄C(jī)器上也沒(méi)有python的管理工具pip,所以也一并安裝
1. 安裝pip
sudo easy_install pip
pip 安裝成功就可以直接安裝pil或者pillow
2. 通過(guò)命令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...
弄了會(huì)別的回來(lái)發(fā)現(xiàn)還沒(méi)有下載完,這叫一個(gè)慢呀,于是放棄
4. Git
通過(guò)git下載源碼地址https://github.com/python-imaging/Pillow
git clone https://github.com/python-imaging/Pillow.git
然后開(kāi)始編譯安裝
4.1
python setup.py build_ext -i
編譯完之后會(huì)提示運(yùn)行測(cè)試?yán)?,并且發(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 因?yàn)镴PEG support not available,運(yùn)行python selftest.py報(bào)告錯(cuò)誤
1 tests of 57 failed.
于是只好卸載pillow
可以通過(guò)pip命令來(lái)卸載
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
- Python基于pillow庫(kù)實(shí)現(xiàn)生成圖片水印
- python實(shí)現(xiàn)按鍵精靈找色點(diǎn)擊功能教程,使用pywin32和Pillow庫(kù)
- Python3 使用pillow庫(kù)生成隨機(jī)驗(yàn)證碼
- Linux上安裝Python的PIL和Pillow庫(kù)處理圖片的實(shí)例教程
- Python利用Pillow(PIL)庫(kù)實(shí)現(xiàn)驗(yàn)證碼圖片的全過(guò)程
- Python Pillow(PIL)庫(kù)的用法詳解
- 詳解Python圖像處理庫(kù)Pillow常用使用方法
- Python編程圖形庫(kù)之Pillow使用方法講解
- python pillow庫(kù)的基礎(chǔ)使用教程
相關(guān)文章
python實(shí)現(xiàn)替換word中的關(guān)鍵文字(使用通配符)
今天小編就為大家分享一篇python實(shí)現(xiàn)替換word中的關(guān)鍵文字(使用通配符),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-02-02
Python用zip函數(shù)同時(shí)遍歷多個(gè)迭代器示例詳解
這篇文章主要給大家進(jìn)行介紹了Python如何用zip函數(shù)同時(shí)遍歷多個(gè)迭代器,文中給出了示例以及原理和注意事項(xiàng),相信會(huì)對(duì)大家的理解和學(xué)習(xí)很有幫助,有需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2016-11-11
Python中使用Frozenset對(duì)象的案例詳解
Frozensets提供了一種創(chuàng)建不可變的集合的方法,它們只接受唯一的元素,并且是可散列類(lèi)型的對(duì)象,所以它們可以在其他只接受可散列對(duì)象作為子對(duì)象的?Python?對(duì)象中使用,這篇文章主要介紹了如何在Python中使用Frozenset對(duì)象,需要的朋友可以參考下2022-08-08
Python實(shí)現(xiàn)的讀取電腦硬件信息功能示例
這篇文章主要介紹了Python實(shí)現(xiàn)的讀取電腦硬件信息功能,結(jié)合實(shí)例形式分析了Python基于wmi庫(kù)讀取電腦CPU、磁盤(pán)、網(wǎng)絡(luò)、進(jìn)程等硬件信息相關(guān)操作技巧,需要的朋友可以參考下2018-05-05
人臉檢測(cè)實(shí)戰(zhàn)終極之OpenCV+Python實(shí)現(xiàn)人臉對(duì)齊
這篇文章主要是為了演示如何使用 OpenCV、Python 和面部標(biāo)志從而實(shí)現(xiàn)對(duì)齊人臉。文中示例代碼對(duì)我們的工作或?qū)W習(xí)有一定的幫助,感興趣的小伙伴可以學(xué)習(xí)一下2021-12-12
關(guān)于ResNeXt網(wǎng)絡(luò)的pytorch實(shí)現(xiàn)
今天小編就為大家分享一篇關(guān)于ResNeXt網(wǎng)絡(luò)的pytorch實(shí)現(xiàn),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-01-01
解決TensorFlow訓(xùn)練內(nèi)存不斷增長(zhǎng),進(jìn)程被殺死問(wèn)題
今天小編就為大家分享一篇解決TensorFlow訓(xùn)練內(nèi)存不斷增長(zhǎng),進(jìn)程被殺死問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-02-02

