Use external packages python 3dsmax



I’m trying to work with image and python
I would like to use pillow or pygame , to do some stuff.
Even if I achieve to install with pip the packages, I have some dll error, due to what I read here probably.

Note: Python 2.7.12 is compiled with VC9.0, while 3ds Max 2019 (and its version of 3dsmaxpy.exe) is compiled with VC14.0. This means that you need to recompile CPython extension libraries for use with Python in 3ds Max with the more recent compiler.

I think this the reason why I cannot work with pillow or pygame

How di you face this problem?


Did you know that the python multiprocessing library has a method that lets you run a different python executable? Because I sure didn’t until I started researching your problem.

I’m guessing you can use the multiprocessing interface to kick off a system python process to run your extension dependent code.


One thing to watch out for is that the python process you kick off will inherit the current processes environment.
This could be good or bad depending on what you’re attempting to do.

On the maya side I’ve had better luck kicking off mayapy.exe with subprocess to call a script that then taps into multiprocessing


Yeah, that environment thing could definitely come back to bite you… Though maybe just inserting some known paths into the beginning of sys.path could be enough, mixing imports from two different pythons sounds dangerous.

Using subprocess may be the way to go, but the data IO that feels like it would be a pain. Lots of reading and writing files. That’s why I looked at multiprocessing. It handles the data management for you via pickles and pipes. If you could set the multiprocessing environment, it would be a nice solution.

Hmmm… Sounds like that’s a module that could be written. Build a class that sets the executable and environment of a python process. Then have a call signature like
returnVal = externalClass(myFunc, args, kwargs)
that builds the process in the correct environment, and handles the pickle/pipe data transfer. I’m guessing most of the code could be copied directly from multiprocessing. I may play with that at some point


This a great workaround usefull and I will investigate on it, but still I do not understand the real reason why my package are not working , and what shoudl I do , because clearly,reding the doc, for Autodesk it is pobbile to use external package with mayapy and 3dsmaxpy.


Actually, it works just about exactly the way it is described in Autodesk reference.
You need to build some packages in order for it to work.

This command from the docs will download, build and install the Pillow:

pip install --no-cache-dir --no-binary pillow pillow

Since I don’t have zlib and jpeg environment set up it will fail for me without some additional options specified:

pip install --no-cache-dir --no-binary pillow --global-option="build_ext" --global-option="--disable-zlib" --global-option="--disable-jpeg" pillow

(It’s not particularly useful though since it cannot handle PNG, JPG or any format that requires zlib/jpeg, but you get the idea)

Tested with Max 2018/19.


I’ll test again today .
I didn’t tought about the zlib/jpeg dependency.
Thanks for the hint


To answer the original question (which I missed for some reason) on the Maya side of things where we face a similar problem of cpython incompatibilities, we just rebuild the extension from source.

In the case of pillow you’d need to ensure that you’ve got all of the dependencies built with the proper version of visual studio, and then finally build the extension. Its possible that these have already been built by someone out there and you just need to point the setup script at these pre-compiled versions.