Take the 2-minute tour ×

I have a virtualenv with --no-site-packages and am having all sorts of issues installing PIL in the virtualenv. The global PIL works fine. I'm trying to get this working by symlinking to PIL in the global site packages, which I know works. I tried:

ln -s /Library/Python/2.6/site-packages/PIL ~/my_virtualenv/lib/python2.6/site-packages/PIL

When I then try to import PIL from Python, that works fine. However I can't run import Image but this works for the system Python. I also tried just copying the directory wholesale, but no dice there either.

Any ideas on how to debug this? How does PIL export Image to the global "module space?"

Update: Thanks to @Sentinel's persistance, I was able to solve this problem. Examining the trace when installing PIL, I noticed a bunch of lines like so:

ld: warning: in /opt/local/lib/libjpeg.dylib, missing required architecture ppc in file
ld: warning: in /opt/local/lib/libz.dylib, missing required architecture ppc in file

Those are actual all the errors that are left, but originally there were others complaining about how I didn't have libjpeg for i386 or x64 architectures as well. So I backed up, removed the libjpeg I had installed to /usr/local/lib and just used macports to install the universal binaries (basically following the instructions at http://passingcuriosity.com/2009/installing-pil-on-mac-os-x-leopard/). Figuring this is what was causing the problem, libjpeg wasn't compiled for the architecture I needed. After doing that, I then installed the Imaging library and then everything worked -- no symlinking required. And now I can go to bed without thinking about this anymore, even if it took 4 hours to figure out. :)

share|improve this question
"all sorts of issues installing PIL" means what? –  Andreas Jung May 24 '11 at 5:57
Symlinking into a virtualenv environment is scary. –  Andreas Jung May 24 '11 at 5:58
Why an upvote here? Symlinking here is weird and scary –  Andreas Jung May 24 '11 at 5:58
@Sentinel I've tried to install PIL with pip install PIL in the virtualenv, but end up with errors like "Symbol not found: _jpeg_resync_to_restart." I went through a dozen different posts and tried a number of things to resolve this, but no luck. I just want to get this up add running. They recommend symlinking here: groups.google.com/group/python-virtualenv/browse_thread/thread/…. I'd be fine copying the whole directory just to get this working because I'm wasting a lot of time on this. –  Bialecki May 24 '11 at 6:08
full tracebacks please - try to solve ther real problem instead of building dirty workarounds. –  Andreas Jung May 24 '11 at 6:28

1 Answer 1

Install the development libraries (jpeg, zip, etc.), then use the virtualenv (adding setuptools or pip to it as necessary) to install PIL into the virtualenv itself.

share|improve this answer

Your Answer


