在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)文章
pd.DataFrame統(tǒng)計(jì)各列數(shù)值多少的實(shí)例
今天小編就為大家分享一篇pd.DataFrame統(tǒng)計(jì)各列數(shù)值多少的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-12-12Python模擬登錄之滑塊驗(yàn)證碼的破解(實(shí)例代碼)
這篇文章主要介紹了Python模擬登錄之滑塊驗(yàn)證碼的破解(實(shí)例代碼),代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-11-11通過(guò)LyScript實(shí)現(xiàn)從文本中讀寫(xiě)ShellCode
LyScript 插件通過(guò)配合內(nèi)存讀寫(xiě),可實(shí)現(xiàn)對(duì)特定位置的ShellCode代碼的導(dǎo)出。本文將利用這一特性實(shí)現(xiàn)從文本中讀寫(xiě)ShellCode,感興趣的可以了解一下2022-08-08Matlab中的mat數(shù)據(jù)轉(zhuǎn)成python中使用的npy數(shù)據(jù)遇到的坑及解決
這篇文章主要介紹了Matlab中的mat數(shù)據(jù)轉(zhuǎn)成python中使用的npy數(shù)據(jù)遇到的坑及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12Python工程師面試題 與Python基礎(chǔ)語(yǔ)法相關(guān)
這篇文章主要為大家分享了Python工程師面試題,面試題的內(nèi)容主要與Python基礎(chǔ)語(yǔ)法相關(guān),感興趣的小伙伴們可以參考一下2016-01-01PyTorch?使用torchvision進(jìn)行圖片數(shù)據(jù)增廣
本文主要介紹了PyTorch?使用torchvision進(jìn)行圖片數(shù)據(jù)增廣,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05