问题:在Linux中安装Pillow(Python模块)期间失败

我正在尝试使用pip安装Pillow(Python模块),但是会引发以下错误:

ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

因此,正如错误所述,我尝试了:

pip install pillow --global-option="--disable-jpeg"

但是它失败了:

error: option --disable-jpeg not recognized

有什么提示如何处理吗?

I’m trying to install Pillow (Python module) using pip, but it throws this error:

ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting

So as the error says, I tried:

pip install pillow --global-option="--disable-jpeg"

But it fails with:

error: option --disable-jpeg not recognized

Any hints how to deal with it?


回答 0

有报道枕头的错误在这里,这表明libjpegzlib现在需要的枕头3.0.0。

Linux上Pillow 的安装说明提供了有关如何安装这些软件包的建议。请注意,并非以下所有软件包都可能在您的计算机上丢失(注释表明libjpeg8-dev实际上仅缺少这些软件包)。

点/ PyPi(枕头> 3.4.2)

最新版本枕头的可PyPI上的轮子 – Python的新标准包装机制。这些预构建的软件包包括所有必要的二进制依赖关系,以允许Pillow运行,如果要使用PyPi安装Pillow,则应使用这些预构建包。

要使用轮子,您需要具有的版本pip>=1.4。如果您使用的是早期版本(pip --version),请使用以下方法升级pip:

pip install --upgrade pip 

一旦pip升级,pip install将在默认情况下,如果他们都可以使用特定于平台的轮文件。使用以下命令将Pillow升级到PyPi上可用的最新版本:

pip install --upgrade pillow

Ubuntu 12.04 LTS或Raspian Wheezy 7.0

sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk

Ubuntu 14.04

sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk

Ubuntu 18.04

sudo apt install libjpeg8-dev zlib1g-dev

软呢帽20

的Fedora 20当量的libjpeg8-devlibjpeg-devel

sudo yum install libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel

Mac OS X(通过Homebrew)

在带有Homebrew的 Mac OS X上,可以使用以下方法解决此问题:

brew install libjpeg zlib

您可能还需要使用以下命令强制链接zlib:

brew link zlib --force

20194月更新:在Mojave中,以上操作不起作用,您需要运行此错误报告(取自Pillow上的此错误报告)

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

2016年7月更新:zlib主存储库中不再有可用的公式(Homebrew将提示您安装lzlib哪个是其他库,将无法解决此问题)。

还有就是在可用公式受骗者库。您可以点击此存储库,然后按常规安装:

brew tap homebrew/dupes
brew install zlib

或者,您也可以改为zlib通过安装xcode,如下所示:

xcode-select --install

感谢凤凰城,Panos Angelopoulou,nelsonvarela,benjaminz和Kal在评论中

这些安装后,枕头的点子安装应该可以正常工作。

There is a bug reported for Pillow here, which indicates that libjpeg and zlib are now required as 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

Ubuntu 12.04 LTS or Raspian Wheezy 7.0

sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk

Ubuntu 14.04

sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk

Ubuntu 18.04

sudo apt install libjpeg8-dev zlib1g-dev

Fedora 20

The Fedora 20 equivalent of libjpeg8-dev is libjpeg-devel.

sudo yum install libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel

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

Update April 2019: In Mojave the above will not work and you need to run the following as taken from this bug report on Pillow

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

Update July 2016: 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 phoenix, Panos Angelopoulou, nelsonvarela, benjaminz and Kal in the comments

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


回答 1

在Raspberry pi II上,我遇到了同样的问题。尝试以下方法后,我解决了问题。解决方案是:

sudo apt-get update
sudo apt-get install libjpeg-dev

On Raspberry pi II, I had the same problem. After trying the following, I solved the problem. The solution is:

sudo apt-get update
sudo apt-get install libjpeg-dev

回答 2

谢谢@mfitzp。就我而言(CentOS),这些库在yum存储库中不可用,但实际上解决方案甚至更容易。我做了什么:

sudo yum install python-devel
sudo yum install zlib-devel
sudo yum install libjpeg-turbo-devel

至此,枕头的安装成功完成。

Thank you @mfitzp. In my case (CentOS) these libs are not available in the yum repo, but actually the solution was even easier. What I did:

sudo yum install python-devel
sudo yum install zlib-devel
sudo yum install libjpeg-turbo-devel

And now pillow’s installation finishes successfully.


回答 3

最快的解决方法是提高点子。确实为我工作:

pip install --upgrade pip

The quickest fix is upgrate the pip. Did worked for me:

pip install --upgrade pip

回答 4

这对我有用。

   `sudo apt-get install libjpeg-dev`

This worked for me.

   `sudo apt-get install libjpeg-dev`

回答 5

brew install zlib

在OS X上不再工作,而是提示安装lzlib。安装没有帮助。

相反,您需要安装XCode命令行工具,并且应该安装 zlib

xcode-select --install
brew install zlib

on OS X doesn’t work anymore and instead prompts to install lzlib. Installing that doesn’t help.

Instead you install XCode Command line tools and that should install zlib

xcode-select --install

回答 6

这对我来说解决了jpeg和zlib错误:

C:\Windows\system32>pip3 install pillow --global-option="build_e
xt" --global-option="--disable-zlib" --global-option="--disable-jpeg"

This worked for me to solve jpeg and zlib error :

C:\Windows\system32>pip3 install pillow --global-option="build_e
xt" --global-option="--disable-zlib" --global-option="--disable-jpeg"

回答 7

ValueError: zlib is required unless explicitly disabled using --disable-zlib将点子从7.x升级到8.y可以解决问题。

所以我会先尝试更新工具。

可以使用以下方法完成:

pip install --upgrade pip

I had the ValueError: zlib is required unless explicitly disabled using --disable-zlib but upgrading pip from 7.x to 8.y resolved the problem.

So I would try to update tools before anything else.

That can be done using:

pip install --upgrade pip

回答 8

如果您不想安装libjpeg,也可以选择:

CFLAGS="--disable-jpeg" pip install pillow

来自https://pillow.readthedocs.io/zh/3.0.0/installation.html#external-libraries

The alternative, if you don’t want to install libjpeg:

CFLAGS="--disable-jpeg" pip install pillow

From https://pillow.readthedocs.io/en/3.0.0/installation.html#external-libraries


回答 9

尝试

pip install pillow

如果不起作用,请尝试清除

cache by pip install --upgrade pip

然后再次运行

pip install pillow

Try

pip install pillow

If it doesn’t work, try clearing the

cache by pip install --upgrade pip

Then again run

pip install pillow

回答 10

在debian / ubuntu上,您只需要:libjpeg62-turbo-dev

所以一个简单sudo apt install libjpeg62-turbo-dev 而又pip install pillow

On debian / ubuntu you only need: libjpeg62-turbo-dev

So a simple sudo apt install libjpeg62-turbo-dev and a pip install pillow


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。