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 figu开发者_开发技巧re out. :)
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.
精彩评论