2
votes

I'm getting this error when I tried to install PIL on my osx lion -

"You must `brew link jpeg' before pil can be installed"

So I followed that instruction, but got another error instead -

"Linking /usr/local/Cellar/jpeg/8d... Warning: Could not link jpeg. Unlinking... Error: Could not symlink file: /usr/local/Cellar/jpeg/8d/bin/wrjpgcom Target /usr/local/bin/wrjpgcom already exists. You may need to delete it. To force the link and delete this file, do:"

I found a post in the site - https://superuser.com/questions/402032/brew-link-jpeg-issues - but doesn't solve my problem. Can anyone tell me how can I resolve this issue?

3

3 Answers

2
votes

From your own link, I learned to try

brew cleanup

then I could just link as needed.

2
votes

I went into the exactly same problem as you, it takes me one hour to solve it. try

brew link jpeg

it will give you some hint, like

"Linking /usr/local/Cellar/jpeg/8d... Warning: Could not link jpeg. Unlinking... Error: Could not symlink file: /usr/local/Cellar/jpeg/8d/bin/wrjpgcom Target /usr/local/bin/wrjpgcom already exists. You may need to delete it. To force the link and delete this file, do:"

you need to delete it. the uncleaned files...

after several deleting work done,you will find that the uncleaned files are stored in

/usr/local/Cellar/jpeg/8d/bin/

just delete all the files under the dir.

rm -rf /usr/local/Cellar/jpeg/8d/bin/*

then, your environment is basicly clean. try

brew install PIL

it should work.but it's not finished. you will find that after the installation, some error message come up: the link to PIL comes into some problem. unlinking... try

brew link PIL

if it works, all is done. your PIL is well installed. but if you use a virtual environment, you may like to create a soft link to your venv.

ln -s /usr/local/Cellar/pil/1.1.7/lib/python2.7/site-packages/PIL  /Users/nan/social_master/socialvenv/lib/python2.7/site-packages/PIL

hope it's helpful!

0
votes

Got this from stack overflow site itself..

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

brew install libjpeg 
pip install pil

And i forgot to mention that if above commands doesn't do the trick, do this

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”)”

Afterwards you can reinstall PIL through pip or easy_install.Make sure all the compiled stuff from your last run is deleted.