Python 如何使用 pip 在 Windows 上安装 Pillow?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34594800/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install Pillow on Windows using pip?
提问by Paul Vincent Craven
I'm trying to install Pillow 3.1 on Windows. Per the instructions, I should be able to just type in:
我正在尝试在 Windows 上安装 Pillow 3.1。根据说明,我应该能够输入:
pip install Pillow
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. I don't know how to do that magic on Windows. Maybe install Ming or something. But I was really hoping for a simple pip install.
因为现在(我认为从 3.0 之后的版本开始?)安装枕头需要 libjpeg。我不知道如何在 Windows 上实现这种魔法。也许安装Ming什么的。但我真的希望有一个简单的 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. But is there a way to do it with pip on Windows without a lot of extra installs?
是的,我可以通过从非官方存储库列表下载 Pillow 来安装它。但是有没有办法在 Windows 上使用 pip 做到这一点,而无需进行大量额外安装?
采纳答案by Hugo
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. The Windows binaries are now upso 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
.
如果您在此窗口期间需要 Pillow,您可以使用pip install pillow==3.0.0
.
回答by Doogle
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. Since Pillow is not yet made compatible with 3.6 and is supporting only till 3.5.2 this error popped up.
我花了将近一天的时间弄清楚枕头安装有什么问题。直到昨天它都运行良好,从今天起突然停止工作。终于弄明白了,我的队友很少将python升级到3.6版本,现在可以下载了。由于 Pillow 尚未与 3.6 兼容并且仅支持到 3.5.2,因此出现此错误。
Resolution is to check if Pillow supports your version of python. Once I reverted python back to 3.5.2 the installation worked like a charm and no errors encountered.
解决方法是检查 Pillow 是否支持您的 Python 版本。一旦我将 python 恢复到 3.5.2,安装就像一个魅力一样,没有遇到任何错误。
Hope this help resolve your issue.
希望这有助于解决您的问题。
回答by Nikse
I install it By running command prompt as administrator pip install Pillowalso we can mention specific version like pip install Pillow==2.6.1
我通过以管理员身份运行命令提示符来安装它 pip install Pillow我们也可以提到特定版本,如 pip install Pillow==2.6.1