Installing PIL with JPEG support on Mac OS X

2019-01-13 02:44发布

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. I also need JPEG support, so I need a JPEG decoder as well.

I have tried to download the libjpeg sources and compile them, and install PIL, but it doesn't recognize the directory.

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!

Thank you in advance for every reply.

7条回答
对你真心纯属浪费
2楼-- · 2019-01-13 02:48

I used the following binary to get libpng and libjpeg installed systemwide on OSX:

libpng & libjpeg for OSX

Because I already had PIL installed (via pip on a virtualenv), I ran:

pip uninstall PIL
pip install PIL --upgrade

This resolved the decoder JPEG not available error for me.

UPDATE:

If encountering the error encoder jpeg not available, you may need to install libjpeg. If using Homebrew:

brew install libjpeg
查看更多
Rolldiameter
3楼-- · 2019-01-13 02:48

For OSX, pip install PIL had:

--------------------------------------------------------------------
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.

查看更多
老娘就宠你
4楼-- · 2019-01-13 02:51

I installed libjpeg and PIL on Snow and it was migrated without problems to Lion.

I think however that you have the same problem I faced with installing libjpeg 7 on Snow. The solution for me was :

  • Make sure that you are NOT using 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.
  • get (http://www.ijg.org/files/jpegsrc.v7.tar.gz) and do the usual ./configure && make && make install (or whatever the readme says).
  • Before installing PIL but after installing libjpeg, change the “JPEG_ROOT = None” line in my setup.py file to “JPEG_ROOT = libinclude(“/usr/local”)”

I got this from a comment on this blog.

Afterwards you can reinstall PIL through pip or easy_install. Make sure all the compiled stuff from your last run is deleted (sometimes you need to do this manually). I used virtualenv and pip.

查看更多
爷、活的狠高调
5楼-- · 2019-01-13 02:55

Make sure you have homebrew and pip, and then run:

brew install libjpeg
pip install pil
查看更多
欢心
6楼-- · 2019-01-13 02:55

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. Use the pillow package for a compatible PIL fork that finds them correctly.

查看更多
唯我独甜
7楼-- · 2019-01-13 03:08

If you have macports installed, you should do a:

$ sudo port selfupdate
$ sudo port install py27-pil

It's easier than the easy_install + libjpeg method since macports install the right dependencies.

查看更多
登录 后发表回答