Setting up virtual environments for your 3dsmax python projects

Some small scripts to simplify the setup and usage of python in 3dsmax development

Here is the github repository: ogmasoul3d/setupMaxPython

background / why

When working with Python scripting at work, I grew tired of the process of installing packages in a way that made them accessible to 3ds Max. I had also become used to working with virtual environments and didn’t like installing all packages in a single global location.

I prefer keeping only the packages required for a specific project isolated—both for easier version management and to avoid a cluttered namespace. And, honestly, for my own sanity.

When I learned that it was possible to point to the 3ds Max Python instance from an external location, I was happy—but the setup was a bit cumbersome. Having to repeat the same steps every time I started a new project felt unnecessary, and the workflow involved more steps than a typical Python project outside of 3ds Max.

So, being a programmer, I decided to create a small helper script to streamline this process. I’m now sharing it in case there are other Python scripters working with 3ds Max who would find it useful as well.

Happy coding!

Note. This does not use gitbash/bash SH scripting. Instead I use Powershell, since this is available windows machines in the renderfarm.

installation and usage of this…

  1. create a new folder for the python project that you want to work with inside 3dsmax. This folder can be where you want it to be.
cd d:\myProjects\
mkdir awsome_3dsmax_python_script
cd awsome_3dsmax_python_script
  1. clone this repository down into your folder…
git clone https://github.com/ogmasoul3d/setupMaxPython
  1. make sure to update the maxversion.txt to the version of 3dsmax you want to use. You open the file and edit to the version you use. If you are using max 2025 then change to 2025

  2. now run this command in the powershell terminal, this will setup your max and things in your environment

.\setupMaxPython\InstallPipAndVirtualenv.ps1
  1. now it is time to run the setupVenvInCurrentFolder command…
.\setupMaxPython\setupVenvInCurrentFolder.ps1

To start 3dsmax with this virtual python environment active… I recommend running the startMaxLocal.ps1 from the terminal to start max this makes it so you can install things (like pip packages) in the terminal efter max is started and you can reference them without restarting max.

.\setupMaxPython\startMaxLocal.ps1

when setup / install is done

you start max by either

  1. starting a terminal, go to the correct folder for the project and run
.\setupMaxPython\startMaxLocal.ps1
  1. or you double-click the icon on your desktop to start 3dsmax with that virtual environment active

Here are my small powershell scripts to setup:


[!] Before running any scripts, UPDATE maxversion.txt to the version you are targeting. All scripts will read this file to get the version num

Just type the version id directly in the maxversion.txt file… nothing else… ex:

2026

InstallPipAndVirtualenv.ps1

Usage: You need to update the $maxName variable to the version of max you are using and you need to update the $3dsmaxPythonVersion if that has changed. You see the name of the folder for python, inside the program folder for max.

This is done on a freshly installed 3dsmax. You do not need to run this again after it is installed, only if you want to update pip after the initial installation

#this is the correct python folder for max 2021 and 2022
$3dsmaxPythonVersion = "Python37"

This script should:

  1. find the install location of your 3dsmax…
  2. using the python version inside 3dsmax, install the correct pip version and virtualEnv
  3. it also updates pip if you already have it installed

setupVenvInCurrentFolder.ps1

Usage: You need to update the $maxName variable to the version of max you are using and you need to update the $3dsmaxPythonVersion if that has changed. You see the name of the folder for python, inside the program folder for max

This script is run every time I want to setup a new venv for a new project I am working on. I usually copy this script to that folder and let it setup the virtual-environment.

#this is the correct python folder for max 2021 and 2022
$3dsmaxPythonVersion = "Python37"

This script should:

  1. using the PIP and python inside 3dsmax, installed with “InstallPipAndVirtualenv.ps1”
  2. setup up a Venv directory inside the folder where this script is run.

startMaxLocal.ps1

Usage: This is a small helper script that activates venv before starting 3dsmax, this makes the same virtual-environment available to 3dsmax. Which simplifies development

This script is run every time I start 3dsmax, that is using this specific Venv

This script should:

  1. find venv folder in the folder this is run from
  2. activate the venv
  3. start 3dsMax from this terminal with venv activated
  4. this makes everything you install in this virtual-environment accessable to 3dsmax, to import, as well