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.