[Maya 2022] No module named 'xxx' even if the script is in the same folder

[Maya 2022] No module named 'xxx' even if the script is in the same folder

manuel.spkDKCCG
Contributor Contributor
4,635 Views
2 Replies
Message 1 of 3

[Maya 2022] No module named 'xxx' even if the script is in the same folder

manuel.spkDKCCG
Contributor
Contributor

Hí!

Everything works perfectly in Maya 2020, but when I try to run the same script in Maya 2022, I get the following error:

 

__init__.py

__init__.py
#     import startup.setup as setup
# ModuleNotFoundError: No module named 'startup' # 

 

The hierarchy of my scripts is as follows:

RootFolder:

   |--- startup\

   |       |--- setup.py
   |--- __init__.py

I'm getting the error on the import of __init__.py, which doesn't seem to be finding the path startup\setup.py
As I already said, there's no error in Maya 2020, but my sys.path seems to be exactly the same in both cases.

Any idea what may be happening? Could It be some change from Python3 that I'm not taking into account?

 

Thanks!

0 Likes
4,636 Views
2 Replies
Replies (2)
Message 2 of 3

g2m.agent
Collaborator
Collaborator

You should put "__init__.py" in the startup folder.

0 Likes
Message 3 of 3

manuel.spkDKCCG
Contributor
Contributor

Thanks for answering. I missed that an __init__.py already exists in the "startup" folder (my fault, sorry). So, that's not the problem.

I've noticed that if I import as follows, I don't get any errors and it finds the module with no problem:

from .startup import setup as setup


Instead of:

import startup.setup as setup


But I would not like to have to change each script one by one, because there are so many...
So... does anyone know where the problem could come from?

Thanks!

0 Likes