Python extension libraries

Autodesk 3ds Max ships with a pre-built version of PySide 2.0, and is the preferred library for using QT with Python in 3ds Max (see Creating Python Uis). You may install other CPython extension libraries as well. However, while every effort has been made to ensure that CPython extension libraries such as PyQt, SciPy, NumPy, PIL, and so forth work with Python in 3ds Max, Autodesk does not provide technical support for them.

The official binaries of Python 2.7 is compiled with VC9.0, while 3ds Max 2020 (and its version of 3dsmaxpy.exe) is compiled with VC15. This means pre-compiled extension libraries Python are not binary compatible do not work with 3ds Max, and you need to recompile CPython extension libraries for use with Python in 3ds Max with the more recent compiler. See the SDK Requirements topic in the 3ds Max Developer's Guide for specifics about the required Visual Studio and Windows toolset versions. Compiled extension libraries must then be placed at a location that can be found by Python. Python uses the list of directories in the sys.path global variable to find the location of imported Python scripts and extension modules.

Installing PIP for package management

Pip is a package management system for Python. It is useful for managing additional Python modules, including managing building modules from source (for example, NumPy). With Python 2, you will need to obtain the source and re-build the binaries, replacing the ones installed by pip. By default, pip will try to use pre-built binaries. You can force pip to build from source with the --no-binary flag, and specifying a required version (see example below).

Using pip with Python 2

Visual Studio 2017 (with VC15.0) must be installed to build libraries from source.

To install pip:

  1. Obtain the get-pip.py script, for example from https://bootstrap.pypa.io/get-pip.py, and save it in <3ds Max Install>\scripts\Python\.
  2. Open a command prompt in <3ds Max Install> and run: 3dsmaxpy.exe scripts\\Python\\get-pip.py
  3. Once pip is installed, you can use it for package installation by running it directly from the <3ds Max Install\>\\Python\\scripts directory. For example, to install Pillow, open a command prompt in <3ds Max Install>\Python\scripts, and run: pip install --no-cache-dir --no-binary pillow pillow==5.0.0. This will download, compile and install Pillow.

Note: Many CPython libraries have additional requirements. NumPy, for example, also requires a Fortran77 compiler, and has several additional dependencies. The Pillow example above requires Zlib and libjpeg (at minimum) be present on the system. Check the specific library's project page for information about any dependencies you will need to obtain.

Note: Use the --no-cache-dir option if Python is installed on your computer.

Note: By default, 3dsmaxpy.exe handles the case where there is a space in the path of the 3ds Max python install. You can disable this feature by setting an environment variable, \__disable_space_handling to FALSE.