简体   繁体   English

在Mac OS X上安装支持JPEG的PIL

[英]Installing PIL with JPEG support on Mac OS X

I posted a question before regarding this subject, and read other ones posted before, but none has successfully solved my problem. 我之前发过一个关于这个主题的问题,并阅读之前发布的其他问题,但没有一个问题成功解决了我的问题。

I am trying to install PIL on Mac OS X Lion, as I need it for a Django application. 我正在尝试在Mac OS X Lion上安装PIL,因为我需要它用于Django应用程序。 I also need JPEG support, so I need a JPEG decoder as well. 我还需要JPEG支持,所以我也需要一个JPEG解码器。

I have tried to download the libjpeg sources and compile them, and install PIL, but it doesn't recognize the directory. 我试图下载libjpeg源并编译它们,并安装PIL,但它无法识别该目录。

So what I would like, and I believe this exists somewhere, is a method to install both PIL and libjpeg with a package installer, without the need for any compilation whatsoever! 所以我想要的,我相信它存在于某个地方,是一种用包安装程序安装PIL和libjpeg的方法,无需任何编译!

Thank you in advance for every reply. 每个回复都要提前感谢您。

In our virtualenv we found all we needed to do was: 在我们的virtualenv中,我们发现我们需要做的就是:

pip uninstall PIL
brew install libjpeg
pip install PIL

which is simpler than some of the above and may be enough for others with this problem too. 这比上面的一些简单,对于其他有这个问题的人来说也足够了。 Although there was an xcode warning on the brew and a setup.py package warning on the reinstall of PIL, all the tests that previously failed with jpeg decode errors successfully ran after just the quick action above. 虽然brew上有一个xcode警告,并且在重新安装PIL时出现了setup.py包警告,但是之前上述快速操作之后,所有先前因jpeg解码错误而失败的测试都成功运行。

I installed libjpeg and PIL on Snow and it was migrated without problems to Lion. 我在Snow上安装了libjpeg和PIL,它没有问题地迁移到Lion。

I think however that you have the same problem I faced with installing libjpeg 7 on Snow. 不过我认为你在Snow上安装libjpeg 7时会遇到同样的问题。 The solution for me was : 我的解决方案是:

  • Make sure that you are NOT using GCC 4.0. 确保您没有使用GCC 4.0。 That means those export lines in your .bash_profile file that you needed to get MySQLdb working now need to go away. 这意味着你的.bash_profile文件中你需要让MySQLdb工作的那些导出行现在需要消失。
  • get ( http://www.ijg.org/files/jpegsrc.v7.tar.gz ) and do the usual ./configure && make && make install (or whatever the readme says). 得到( http://www.ijg.org/files/jpegsrc.v7.tar.gz )并执行通常的./configure && make && make install(或者自述文件)。
  • Before installing PIL but after installing libjpeg, change the “JPEG_ROOT = None” line in my setup.py file to “JPEG_ROOT = libinclude(“/usr/local”)” 在安装PIL但安装libjpeg之前,将setup.py文件中的“JPEG_ROOT = None”行更改为“JPEG_ROOT = libinclude(”/ usr / local“)”

I got this from a comment on this blog . 我从这篇博客的评论中得到了这个。

Afterwards you can reinstall PIL through pip or easy_install. 之后,您可以通过pip或easy_install重新安装PIL。 Make sure all the compiled stuff from your last run is deleted (sometimes you need to do this manually). 确保删除上次运行中的所有已编译内容(有时您需要手动执行此操作)。 I used virtualenv and pip. 我使用了virtualenv和pip。

Make sure you have homebrew and pip, and then run: 确保你有自制和pip,然后运行:

brew install libjpeg
pip install pil

I used the following binary to get libpng and libjpeg installed systemwide on OSX: 我使用以下二进制文件来获取OSX上系统范围内安装的libpng和libjpeg:

libpng & libjpeg for OSX 用于OSX的libpng和libjpeg

Because I already had PIL installed (via pip on a virtualenv), I ran: 因为我已经安装了PIL(通过virtualenv上的pip),我跑了:

pip uninstall PIL
pip install PIL --upgrade

This resolved the decoder JPEG not available error for me. 这为我解决了decoder JPEG not available错误。

UPDATE: 更新:

If encountering the error encoder jpeg not available , you may need to install libjpeg . 如果遇到错误encoder jpeg not available ,您可能需要安装libjpeg If using Homebrew : 如果使用Homebrew

brew install libjpeg

For OSX, pip install PIL had: 对于OSX,pip install PIL有:

--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      darwin 2.7.2 (default, Oct 11 2012, 20:14:37)
              [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------

Another post led to something that works. 另一个帖子带来了一些有用的东西。

Install the libraries from here . 这里安装库。

Worth noting and good information to have whenever working with Python and PIL: If you use virtualenv (and I think it's a very good idea), PIL may not correctly detect the image libraries on your system and install without JPEG/PNG support. 值得注意的是,无论何时使用Python和PIL都有好的信息:如果你使用virtualenv(我认为这是一个非常好的主意),PIL可能无法正确检测系统上的图像库并在没有JPEG / PNG支持的情况下安装。 Use the pillow package for a compatible PIL fork that finds them correctly. 使用枕头包装可以正确找到兼容的PIL前叉。

If you have macports installed, you should do a: 如果您安装了macport,则应该执行以下操作:

$ sudo port selfupdate
$ sudo port install py27-pil

It's easier than the easy_install + libjpeg method since macports install the right dependencies. 它比easy_install + libjpeg方法更容易,因为macports安装了正确的依赖项。

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

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