mayapy tips

We’ve been covering the use of Maya’s Python Environment in a series of posts on this website. In the previous post, we set up our editing environment and experimented with code completion using eclipse. You can read all about it here. One addition to the original post about mayapy follows:

We have shown how to create an environmental variable to store the location of mayapy within Maya.app. Executing the python interpreter could then be accomplished by typing
$MAYA_LOCATION/bin/mayapy at the command prompt.

To automate things a bit further, why not put mayapy into the path? Well that’s a bad idea because there are many other applications in the maya path that might conflict with your regular installation of python. One small workaround is to create a shell script in /usr/local/bin that can execute mayapy for you!

It’s as simple as creating a text file and saving it in a hidden directory.

In Textmate you can create a new document with the following code:

mayapy shell script

then, when saving, hit COMMAND-SHIFT-G to go to a location manually. This is a great little trick that works throughout the finder in OS X.

Go To a custom location

Then you can save this as /usr/local/bin/mayapy. It will prompt you for an administrative password.

The final step is to add execute permissions to the newly created file.

At the terminal you can type

sudo chmod +x /usr/local/bin/mayapy

and you are ready to roll! Now you can just type mayapy at any command prompt to launch the python environment!

Editing Environment

mayapy hello world

Powered by WordPress