question

François Beaune avatar image
François Beaune asked ·

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.

mtoaarnold5python
1 comment
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

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

0 Likes 0 · ·
Stephen Blair avatar image
Stephen Blair answered ·

In ai_universe.py, change line 7 to this:

from .ai_nodes import *
Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Tyler Furreboe avatar image
Tyler Furreboe answered ·

@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
Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

François Beaune avatar image
François Beaune answered ·

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

Share
10 |600 characters needed characters left characters exceeded

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 2.0 MiB each and 9.8 MiB total.

Welcome to the Arnold Answers community.

This is the place for Arnold renderer users everywhere to ask and answer rendering questions, and share knowledge about using Arnold, Arnold plugins, workflows and developing tools with Arnold.

If you are a new user to Arnold Answers, please first check out our FAQ and User Guide for more information.

When posting questions, please be sure to select the appropriate Space for your Arnold plugin and include the plugin version you are using.

Please include images, scene and log files whenever possible as this helps the community answer your questions.

Instructions for generating full verbosity log files are available for MtoA, MaxtoA, C4DtoA, HtoA, KtoA, and Kick.

If you are looking for Arnold Documentation and Support please visit the Arnold Support site.

To try Arnold please visit the Arnold Trial page.

Bottom No panel present for this section.