Community
Arnold General Rendering Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't import arnold module with Python 3

4 REPLIES 4
Reply
Message 1 of 5
franz
827 Views, 4 Replies

Can't import arnold module with Python 3

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.

Tags (3)
Labels (3)
4 REPLIES 4
Message 2 of 5
franz
in reply to: franz

Sorry for the formatting but the text editor is extremely buggy...

Message 3 of 5
Stephen.Blair
in reply to: franz

In ai_universe.py, change line 7 to this:

from .ai_nodes import *


// Stephen Blair
// Arnold Renderer Support
Message 4 of 5
franz
in reply to: franz

@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.

Message 5 of 5
tfurrebo
in reply to: franz

@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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report