With Arnold 5.2.0.0 that ships with Maya 2017, the following code works with Python 2.7 but fails with Python 3.6:
import os import sys sys.path.insert(0, 'C:/solidangle/mtoadeploy/2017/scripts') os.environ['PATH'] += ';C:/solidangle/mtoadeploy/2017/bin' import arnold print(arnold.AiGetVersion())
Here's the output with Python 2.7:
['5', '2', '0', '0']
and the error with Python 3.6:
Traceback (most recent call last): File "D:\temp\test.py", line 7, in <module> import arnold File "C:/solidangle/mtoadeploy/2017/scripts\arnold\__init__.py", line 6, in <module> from .ai_color_managers import * File "C:/solidangle/mtoadeploy/2017/scripts\arnold\ai_color_managers.py", line 7, in <module> from .ai_nodes import * File "C:/solidangle/mtoadeploy/2017/scripts\arnold\ai_nodes.py", line 9, in <module> from .ai_universe import AtUniverse File "C:/solidangle/mtoadeploy/2017/scripts\arnold\ai_universe.py", line 7, in <module> import ai_nodes ModuleNotFoundError: No module named 'ai_nodes'
This is caused by this `import ai_nodes` statement.
Interestingly, Arnold 5.1.1.1 does not have that statement and consequently the sample code works fine with Python 3.6.
In ai_universe.py, change line 7 to this:
from .ai_nodes import *
@Stephen Blair: That's not enough as the code references the ai_nodes package name later on, for instance
return NullToNone(func(universe), POINTER(ai_nodes.AtNode))
in `_AiUniverseGetOptions()`. Removing all `ai_nodes.` prefixes appears to solve the problem.
@François Beaune I solved it by changing line 7 in ai_universe.py to this, you'll have to ensure arnold is apart of your PATH environment variable:
from arnold import ai_nodes