Skip to content

How to create a Python library directory in PyCharm for Maya

A brief introduction on creating a new python library using PyCharm for use in Autodesk Maya. Libraries are related code that is packaged together.

Create a new directory in PyCharm, click ‘New’ > ‘Python Package’:

‘New’ > ‘Python Package’

Give it a name and click ‘OK’

Im calling it ‘conLibrary’ for ‘Controller Library’

Libraries are used in python to contain related code together as a ‘packaged’ library

You can see that a new folder has been created and it contains a __init__.py file, this tells Python that this is a package and not just a directory.

The __init__.py file within our new package

Create a new file in this directory called ‘controllerLibrary.py’:

Lets put something in this file to confirm that we can find it within Maya, a print command is an easy place to start:

Print "I am a controller library"

Then from within Maya we’ll run the following command to confirm our new library is being found.

from conLibrary import controllerLibrary
reload(controllerLibrary)

We can see in the output that the print statement we defined in the controllerLibrary.py script is confirmed in the output:

We have confirmed that our library is being found from within Maya.
Published inMayaPyCharmPythonscripting