Saturday, March 12, 2011

If Maya Python doesn't find your package


I am often faced with the problem - maya dont finded pakage modules
even path to the module present in PYTHONPATH environment variable.
And in feedback return something like this:
import  LightZeppelin
# Error: ImportError: line 1 of <maya console>: No module named LightZeppelin #
Early I solved this problem with

import sys
sys.path.append('myPath to package')
This is just work. But there is one more solution for this problem:

create your own *.pth file in $MAYA_LOCATION/lib/python2.6/site-packages directory

In my case - this is LightZeppelin.pth file contained one string - full path to DIRECTORY conteined "LightZeppelin" package.
This is very important. For example, if your pakage placed by /my_toolkit/my_subfolder/my_package 
then in *.pth Your must write:
/my_toolkit/my_subfolder/
And after this one maya python finded your "my_package" by
import my_package

No comments:

Post a Comment