Check if your extension module was built and linked against a different version of Python. In order to use a CPython module with Python in 3ds Max, you must compile the CPython binaries against Python version 3.9. See Python extension libraries for more information.
Update the registry or manually install the module. Often modules support installation via manual steps or a Python module (for example, the Python "easy_install" module (http://pythonhosted.org/distribute/easy_install.html). See also Python extension libraries for more information.
In Python, if you misspell a property when assigning it, a new field is added to the object as a result - for example: MyClass.fOotball = x, or worse yet: MyClass.GetValue = 42. It is legal to add or replace fields on an object at run-time; therefore no error occurs. The safest way to set a property is to use a Set
function, for example: render.SetWidth(640).
When you run any Python code that affects the global environment (for example, importing a module), those settings persist during your session of 3ds Max. A common mistake is to rely on a module that was imported by another script, or to call a function that was created by another script.
Use the reload(MyLibraryModule)
command to force Python to reload that module.
When sys.exit()
is used to exit Python, it raises a SystemExit
exception. If an uncaught exception is raised in Python, it is reported to the MAXScript Listener window as an error, even though no error actually occurred. To avoid having an error being reported in the MAXScript Listener window by sys.exit()
, you can use the try
and except
statements as follows:
try:
import sys
print \'goodbye world\'
sys.exit() # Safe way to leave program at any point and allow objects and resources to be cleaned up.
# Prevent 3ds Max from reporting a system exit as an error in the listener.
except SystemExit:
pass
If you import a module in a script, the module remains "imported" even after you finish executing your script and start executing a different script. Any names added to the global namespace will also remain from script execution to script execution. These only persist per session of 3ds Max, however, and you can workaround this by exiting and reloading 3ds Max.
When creating an instance of QApplication()
, do not use app = QApplication([])
, use instead:
app = PySide2.QtCore.QCoreApplication.instance()
if not app:
...
to avoid a potential crash.
Note Troubleshooting tips for PySide2 also apply to PyQt.
Some modules require that you set sys.argv = ['']
before you use them; for example, app = QtGui.QApplication(sys.argv)
.
Module names (for example, pymxs
) and built-in functions (for example, dir
) can be re-assigned to anything. This is especially a problem with global variables since it can break other scripts, but is acceptable within the scope of a function.
The sys.path
does not contain the executing script path. This is by design. To get the path of the currently executing script, use the __file__
constant.