Hey guys, I am currently trying to learn Python and tools programming in maya, I have been using a tutorial series from udemy called Python For Maya: Artist Friendly Programming
It was made using maya 2017 however i am running 2020, I was able to make it 65% through the course however i am currently stuck at an area where it had me create a package and im calling a module in the package from another script.
and i have a picture called maya results which shows the error i am getting.
I do apologize for posting about this however this has been my downfall from learning for the past 2 days and i want get it all figured out so i can go back or learning.
Hello, I could maybe help you but I tend to avoid downloading stuff from unknown sources.
Could you please post at least the error message here, and maybe a “pseudo-code” snippet that only show what is relevant. (If it’s a module import issue you could just show us the “import lines” for each of your file and your package structure.)
Cheers.
Liam.
# Error: No module named 'controllerLibrary'
# Traceback (most recent call last):
# File "<maya console>", line 2, in <module>
# File "E:\Program Files\maya2022\Maya2022\Python37\lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
# return original_import(name, *args, **kwargs)
# File "C:/Users/infin/OneDrive/Documents/maya/2022/scripts\conLibrary\libraryUI.py", line 1, in <module>
# from controllerLibrary import ControllerLibrary
# File "E:\Program Files\maya2022\Maya2022\Python37\lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
# return original_import(name, *args, **kwargs)
# ModuleNotFoundError: No module named 'controllerLibrary' #
// Error: file: E:/Program Files/maya2022/Maya2022/scripts/startup/cutCopyPaste.mel line 92: Nothing is currently selected. //
Imports in Maya script editor
from conLibrary import libraryUI
import importlib
libraryUI.py script
from controllerLibrary import ControllerLibrary
from Qt import QtWidgets, QtCore, QtGui
I don’t know if this next one is relevant, but Import lines from controllerLibrary.py
from maya import cmds
import os
import json
import pprint
Modules are a hard one to wrap your head around.
I’m not an expert on this topic so I let others answer the “why”, for now I would suggest using relative import :
Maya 2022 is using python 3 rather than python 2. The import behavior has change in the transition from 2 to 3, so any old code you may be looking at may not work in Maya 2020.