bpy and PIL / Pillow?

Hi all, I’m looking into manipulating images with Pillow in custom node trees. If I install Pillow and copy the PIL directory from

C:\Python34\Lib\site-packages

to

<my blender installation>\bin\2.73\python\lib\site-packages

then I can import PIL just fine. I can save .png image files, but saving to any other image format type crashes Blender.

But if I run Python 3.4 in a command prompt, I can import PIL (the one from my C:\Python34 installation), and read, modify and save to any of the supported image formats.

What could the problem be? Why can’t I do this from within Blender without it crashing?

A remember format related crashes of pillow in Blender, but I never found a cure. Maybe there’s some multithreading in the library which does not play wel with Blender’s event system?

My guess would be that blender and pillow try to link to different libjpeg versions, or the dll you need just isn’t in blender’s path. The one you need is probably somewhere in your c:\Python34\Lib\site-packages. I’m not using Windows, so I can’t check that.

Dang. But I wonder why .png works fine then?? Maybe I’ll ask on stackexchange, see if one of the devs will reply.

I agree with Bayesian. If Pillow is expecting to have some .dll/.so files located in the site-packages directory, then you would have to copy those over to Blender. Missing dynamic libraries could definitely explain your symptoms.

These questions will keep popping up until blender can interface cleanly with modern python package management solutions. Installing stuff like pillow in Python is really easy - except if you have to link to the particular python and library versions your particular blender binary has been linked against.

I am currently trying to build blender against Continuum’s Anaconda Python distribution, but am still stuck in dependency hell… Anyway, this would mean conda+pip support, and all sorts of niceties like pandas, scikit-learn and scikit-image…