Python Environment in Max 22

Python Environment in Max 22

christoph2R9BA
Explorer Explorer
513 Views
2 Replies
Message 1 of 3

Python Environment in Max 22

christoph2R9BA
Explorer
Explorer

Hello Community,

 

In our pipeline we set the environment variables required for our tools with our custom app launcher before max start.

This is a common practice and it worked great.

Until in Max 2022.2 there is a change that means it doesn't load the environment anymore (MAXX-62248)

 

The changelog reads "The python interpreter embedded in 3dsMax no longer uses PYTHON env vars (in a manner similar to the -E switch in command line python)."

So how do we load in our own python environment then. There seems to be no hint on how to do that with the new interpreter.

 

cheers

Christoph

 

0 Likes
514 Views
2 Replies
Replies (2)
Message 2 of 3

attilaszaboo
Community Visitor
Community Visitor

I'm aware of two possible ways to get 3ds Max load your python scripts:

a) Modify sys.path through a Maxscript startup script to include the location of your python scripts\modules

b) Use virtual environments. See this help topic on setting one up. Depending on your context, you may need to do this in a script that will be launching 3ds Max in the context of the activated virtual environment.

I hope this helps.

0 Likes
Message 3 of 3

christoph2R9BA
Explorer
Explorer

So in case anybody stumbles upon the same issue, this is our solution:
make sure to put the environment variables in os.environ["PYTHONPATH"]

then have a ms startup script that just calls a python script, which in turn adds anything on os.environ["PYTHONPATH"] to sys.path

then do a site.addsitedir to add our own virtual env

0 Likes