Maya 2014 with Python’s PIL Module

Since I have not found this anywhere online, here is my version.

For some reason the devs of Autodesk Maya decided to switch to VS2010 for compiling their Python interpreter, starting with Maya 2013 I believe. Non-Maya distributions are compiled with VS2008 which causes a lot of headache when you want to use certain modules in the latest Maya. One of those trouble-makers is PIL (Python Imaging Library) which I use to create slates for vfx shots. Now, you certainly don’t have to do that from within Maya, but sometimes it is nice to be able to, because the slate generation is built into some tool that you run within Maya.

For all of you, who want to use PIL in Maya 2014 with freetype support, download this and it should work. Thanks to Christian Akesson [1] for his version and for documenting his build process. His version lacks the freetype support which is why I could not use it and had to compile it myself. Let me know if this proves useful to you or gives you any trouble.

edit: I probably should have been clearer about this. This is for windows only. If you use a different OS you won’t be able to use the module I provide here. For the Mac users: Have a look at the comments below,- Bill provided a solution for you. Thanks for that, Bill! :)

[1] http://christianakesson.com/2013/4615

Advertisements

24 responses to “Maya 2014 with Python’s PIL Module

  1. hi, I tried to install the module but I keep getting the error “The _imaging C module is not installed” ?? I can’t seem to find a good solution online. BTW I am using a mac running Maveriks

    • Hey Bill,

      you will need a module that was compiled for your OS specifically. I compiled PIL for windows only and I’m afraid I won’t be able to help you because I am not a mac user… I hope you find a solution somewhere!

      Matti.

      • I was able to come up with a solution for mac users. the best way to install home-brew,then enter the command

        brew install Homebrew/python/pillow

        This will install all of the necessary files for mac users to use PIL (pillow is a fork of PIL btw). Finally locate where homebrew installed the PIL folder, and then copy and paste that into mayas scripts folder.
        Worked for both Maya 2014 and 2015

    • Hey Francois,

      mh, it’s been a while since I last dealt with this so my memory is a bit rusty. As I wrote in the post, I think python modules for 2013 need to be compiled with VS2012, as well, so I would think that it works. I won’t make any promises, though, as I haven’t tested. Have you tried? Any problems? :)

      • I believe IOError 2 has nothing to do with PIL but it just tells you that the file you want to open does not exist? Is that possible? What happens if you run os.path.isfile(texture)?

      • import os
        import maya.cmds as cmds
        from PIL import Image
        path = “C:/Users/francesco/Desktop/selectionMaya”
        dir = os.listdir(path)
        junk = [“.mayaSwatches”, “.DS_Store”, “.picasa.ini”]
        for texture in dir:
        if texture not in junk:
        print texture

        with this script I got :
        a.jpg
        b.jpg
        c.JPG
        d.JPG
        e.JPG
        f.JPG
        g.JPG
        h.jpg
        i.jpg
        j.jpg
        k.JPG
        l.JPG
        m.JPG
        n.JPG

        If I replace “print texture” with “print os.path.isfile(texture)” I got 14 times “false”

      • Ah, I see. You need to pass the entire path to the file to those functions. As you see, dir contains only the fileNAMES at the moment but python has no idea where they live. Try joining the path and the filename with os.path.join(path, texture). Then os.path.isfile should find it and PIL as well.

      • yep . the trick was :
        img = Image.open(os.path.join(myFile,texture))
        Thanks for the help

    • woah, I haven’t looked at PIL in ages… What Maya are you running? I compiled this explicitly for Maya2014 and I wouldn’t expect it to work in any other version…

      • Haha Ya sorry to drag this back up from years ago. I’m on Maya 2016. So I can look into compiling the source code specifically for that version… Though I’m not sure what the difference would be. Is it as simple as using a newer version of VS? I’ll try it out and see what happens.

  2. I’m not sure what the difference is either, but they might have changed compiler versions again. Sorry, I didn’t compile anything for Maya in quite a while (or on windows) so I don’t even know what version of VS to use for Maya2016. You could try to attach a debugger and see what it reports during the crash. On linux I’d use gdb but I’ve used WindDbg on Windows before and it helped sometimes… Just a suggestion.

  3. Hi Mistermati. Like Joseph, I am struggling to install Pillow for Python/Maya. Whatever the version of Python 2 or 3, I got a

    # Error: line 1: ImportError: file line 5: No module named PIL #

    Do you know some guys who would have build a Pillow for Windows 10 – 64bits / Maya 2016 ?

    • Hey Francois,

      your error sounds more like the PIL module is not installed in a location known to Python. You can check using ‘sys.path’.

      As for a different build – no, I have no idea. I have built this myself ages ago because I needed it in production, but I haven’t followed up on new versions since then, sorry.

      Matti.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s