Pillow & OpenCV安装

本文档提供了在macOS 10.12.1环境下安装Pillow 3.4和OpenCV 3.2的详细步骤。针对Pillow安装过程中遇到的libjpeg和zlib缺失问题给出了具体解决方案,并介绍了通过Homebrew安装这些依赖的方法。同时,也说明了如何使用pip升级Pillow到最新版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Pillow & OpenCV安装


参考文档:

OpenCV安装请参看官方链接,安装略

环境:
macOS 10.12.1
Pillow 3.4
OpenCV 3.2

There is a bug reported for Pillow here, which indicates that libjpeg and zlib are now requiredas of Pillow 3.0.0. 

The installation instructions for Pillow on Linux give advice of how to install these packages. Note that not all of the following packages may be missing on your machine (comments suggest that only libjpeg8-dev is actually missing).

pip / PyPi (Pillow>3.4.2)

The latest releases of Pillow are available on PyPi as wheels — the new standard packaging mechanism for Python. These prebuilt packages include all neccessary binary dependencies to allow Pillow to run and should be used if you want to install Pillow using PyPi

To use wheels, you need to have a version of pip>=1.4. If you are using an earlier version (pip --version) upgrade pip using the following:

pip install --upgrade pip 

Once pip is upgraded, pip install will use platform-specific wheel files by default if they are available. Use the following command to upgrade Pillow to the latest version available on PyPi:

pip install --upgrade pillow


Mac OS X (via Homebrew)

On Mac OS X with Homebrew this can be fixed using:

brew install libjpeg zlib

You may also need to force-link zlib using the following:

brew link zlib --force

Thanks to Panos Angelopoulous and nelsonvarela in the comments.

Update 5th July 2016: In current versions of Homebrew the above may no longer work, as there is no longer a formula for zlib available in the main repository (Homebrew will prompt you to install lzlib which is a different library and will not solve this problem). 

There is a formula available in the dupes repository. You can either tap this repository, and install as normal:

brew tap homebrew/dupes 
brew install zlib

Or you can install zlib via xcode instead, as follows:

xcode-select --install

Thanks to benjaminz in the comments and Kal's answer below

After these are installed the pip installation of Pillow should work normally.

转载于:https://www.cnblogs.com/lixuebin/p/10813999.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值