0

I have a package folder located in my defaults maya scripts folder. E.g. (C:\Users\USERNAME\Documents\maya\2020\scripts\packageFolder).

The package is basically structured like so:

package/ __init__.py Classes/ ExampleClass.py __init__.py Utils/ SomeUtilModule.py __init__.py 

In my init.py file I try to import modules like so:

from package.Classes import ExampleClass 

what Maya says:

# Error: ImportError: file C:/Users/USERNAME/Documents/maya/2020/scripts\package\__init__.py line 5: No module named Classes # 

What am I doing wrong here?

1
  • Could only test in Maya2023 and it works fine here. Used the same structure as you did. Commented Jun 2, 2022 at 11:10

1 Answer 1

0

I suspect it's not about Maya's implementation, it's about circular imports in your Python code. Probably, your ExampleClass' __init__.py imports from package.

You can read about this by searching for "Python circular imports". Unfortunately, the error description does not show the nature of the problem and is very confusing if you don't know the reason beforehand.

There are plenty of suggestions on how to deal with this, just to name a few: one, two.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.