简体   繁体   English

如何使用 pip 在 Windows 上安装 Pillow?

[英]How to install Pillow on Windows using pip?

I'm trying to install Pillow 3.1 on Windows.我正在尝试在 Windows 上安装 Pillow 3.1。 Per the instructions , I should be able to just type in:根据说明,我应该可以输入:

pip install Pillow

But I get:但我得到:

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

Because now (starting with versions after 3.0 I think?) libjpeg is required for pillow to be installed.因为现在(我认为从 3.0 之后的版本开始?)需要 libjpeg 才能安装枕头。 I don't know how to do that magic on Windows.我不知道如何在 Windows 上施展魔法。 Maybe install Ming or something.也许安装明之类的。 But I was really hoping for a simple pip install.但我真的希望安装一个简单的 pip。

I can disable these options through the intuitive command:我可以通过直观的命令禁用这些选项:

pip install --upgrade pillow --global-option="build_ext" --global-option="--disable-jpeg" --global-option="--disable-zlib"

But then the build fails because I don't have Visual C++ installed.但随后构建失败,因为我没有安装 Visual C++。

Yes, I can install Pillow by downloading it from the unofficial repository list .是的,我可以通过从非官方存储库列表下载来安装 Pillow。 But is there a way to do it with pip on Windows without a lot of extra installs?但是有没有办法在 Windows 上使用 pip 而无需大量额外安装?

By far the easiest thing to do on Windows is install Pillow using pre-built binaries rather than trying to build it yourself.到目前为止,在 Windows 上做的最简单的事情是使用预构建的二进制文件安装 Pillow,而不是尝试自己构建它。

When there's a new Pillow release, it usually takes a day or so for the Windows binaries to be built and uploaded.当有新的 Pillow 版本时,通常需要一天左右的时间来构建和上传 Windows 二进制文件。

You ran into this problem during this window.您在此 window 期间遇到了这个问题。 The Windows binaries are now up so you can install with pip install pillow (or pip install -U pillow ). Windows 二进制文件现已启动,因此您可以使用pip install pillow (或pip install -U pillow )进行安装。

If you need Pillow during this window, you can install a given previous version with binaries like pip install pillow==3.0.0 .如果您在此 window 期间需要 Pillow,您可以使用pip install pillow==3.0.0等二进制文件安装给定的先前版本。

I install it By running command prompt as administrator pip install Pillow also we can mention specific version like pip install Pillow==2.6.1我安装它通过以管理员身份运行命令提示符pip install Pillow我们也可以提到特定版本,如 pip install Pillow==2.6.1

I spent almost a day figuring out what is wrong with pillow installation.我花了将近一天的时间来弄清楚枕头安装有什么问题。 It was working fine till yesterday and suddenly stopped working from today.直到昨天它工作正常,从今天开始突然停止工作。 Finally got it figured out, Few of my team mates upgraded python to 3.6 version which is now available for download.终于弄明白了,我的几个队友把 python 升级到了 3.6 版本,现在可以下载了。 Since Pillow is not yet made compatible with 3.6 and is supporting only till 3.5.2 this error popped up.由于 Pillow 尚未与 3.6 兼容并且仅支持到 3.5.2,因此弹出此错误。

Resolution is to check if Pillow supports your version of python.解决方法是检查 Pillow 是否支持您的 python 版本。 Once I reverted python back to 3.5.2 the installation worked like a charm and no errors encountered.一旦我将 python 恢复到 3.5.2,安装就像一个魅力,没有遇到任何错误。

Hope this help resolve your issue.希望这有助于解决您的问题。

In django models, you can try:在 django 型号中,您可以尝试:

python -m pip install Pillow

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM