From b37359979cd9f52034f77e5df250e7cefe535877 Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Wed, 1 Feb 2023 12:38:02 +0100 Subject: [PATCH] :recycle: force modules to sys.path --- openpype/hosts/max/startup/startup.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/max/startup/startup.py b/openpype/hosts/max/startup/startup.py index 37bcef5db1..21da115baa 100644 --- a/openpype/hosts/max/startup/startup.py +++ b/openpype/hosts/max/startup/startup.py @@ -1,6 +1,20 @@ # -*- coding: utf-8 -*- -from openpype.hosts.max.api import MaxHost -from openpype.pipeline import install_host +import os +import sys + +# this might happen in some 3dsmax version where PYTHONPATH isn't added +# to sys.path automatically +try: + from openpype.hosts.max.api import MaxHost + from openpype.pipeline import install_host +except (ImportError, ModuleNotFoundError): + + for path in os.environ["PYTHONPATH"].split(os.pathsep): + if path and path not in sys.path: + sys.path.append(path) + + from openpype.hosts.max.api import MaxHost + from openpype.pipeline import install_host host = MaxHost() install_host(host)