Our goal is to support the 3 latest versions of Maya. At the time of this writing, that means 2008, 2009, and 2010. While we are no longer officially supporting Maya 8.5 SP1 and python 2.4, this version of PyMEL is still mostly compatible with them. Moving forward we will begin phasing out support for Maya 8.5 and Python 2.4. In the meantime, there are only two aspects of PyMEL that will not work on 8.5:
- No API Undo: node class methods that derive from API will not be undoable
- Data class properties are read-only: operations such as Color().r=1.0 or Vector().x=2.0 will have no effect
| Maya Version | Python Version |
|---|---|
| 8.5 sp1 only | 2.4.3 |
| 2008 (including: sp1, ext1, sp2, ext2) | 2.5.1 |
| 2009 (including: sp1, sp1a) | 2.5.1 |
| 2010 | 2.6.1 |
As of version 0.9.1 PyMEL supports installation via setuptools, which makes it a lot easier to get started if you’re not well-versed in the intricacies of the PYTHONPATH. If you don’t already have setuptools installed it will be downloaded for you when you run the install command below, but in order for this to all go smoothly you must have the following things:
- a connection to the internet
- write permission to your Maya installation directory
If you fall short on either of these you can always perform a Manual Install of PyMEL.
To Install:
Open a shell:
- on osx you’ll find the Terminal app in /Applications/Utilities
- on Windows, open the Start menu then go to “Run...”, then put in cmd and press “OK”
cd to the directory where you extracted the pymel zip file. A file called “setup.py” should exist directly below this directory. For example, I downloaded and extracted mine to my “Downloads” folder on OSX:
cd ~/Downloads/pymel-0.9.2Note
On OSX and Linux you have to escape spaces in folder names ( or you can press the Tab key to auto-complete paths ). Here is an example of escaping a space in a folder name (notice the backslash after Image):
cd /Applications/Image\ Capture.appOn Windows you can copy the path from Explorer and paste into the shell by right clicking. You don’t need to escape spaces.
Now run the installation for each version of Maya that you have installed using Maya’s own python interpreter – aka mayapy. This ensures that PyMEL is installed to the site-packages directory of each, and that it will always be on your PYTHONPATH when using Maya.
On OSX:
sudo /Applications/Autodesk/maya2008/Maya.app/Contents/bin/mayapy setup.py install sudo /Applications/Autodesk/maya2009/Maya.app/Contents/bin/mayapy setup.py installOn Windows wrap the path in double quotes:
"C:\Program Files\Autodesk\Maya2008\bin\mayapy.exe" setup.py install "C:\Program Files\Autodesk\Maya2009\bin\mayapy.exe" setup.py installOn both platforms you should be able to drag and drop the mayapy file from finder/explorer into the shell to get the path.
Note
Be sure to use the proper path to your mayapy.exe. For example, if you have 32-bit maya installed on 64-bit windows, it will be installed to C:\Program Files (x86) instead of C:\Program Files
If the easy install did not turn out to be so easy, PyMEL can always be manually installed like any other python module or package. The process is simple in concept:
- put the pymel folder somewhere
- tell python where to find it
To find available modules, python searches directories set in an environment variable called PYTHONPATH. This environment variable can be set for each Maya installation using the Maya.env file, or it can be set at the system level, which will set it for all instances of python, including those bundled with each Maya installation (aka “mayapy”).
| Maya.env | System-Level | |
|---|---|---|
| allows per-maya configuration of environment variables | YES | NO |
| allows easy execution of maya and mayapy in a shell | NO | YES |
Warning
If you set your PYTHONPATH at the system level it will override any values for PYTHONPATH set in Maya.env, except on OSX when launching Maya from it’s application bundle (an application bundle is the icon you click on to launch Maya).
The instructions below on setting up your python environment are essential to learning how to properly deploy any python module, not just PyMEL, and mastering them is also key to using the Standalone Maya Python Interpreter.
If manually installing PyMEL on linux or osx, simply place the unzipped “pymel” folder in your Maya “scripts” directory. This will allow you to immediately use PyMEL from within Maya. However, it is usually a good idea to create a separate directory for your own python modules so that you can organize them independently of your mel scripts.
Let’s say that you decide to create your python development directory ~/dev/python. Move the pymel folder (the one with pymel.conf directly below it) into ~/dev/python so that it lives at ~/dev/python/pymel. Then add this line to your Maya.env:
PYTHONPATH = ~/dev/python
On, Windows you might create a directory for python development at C:\My Documents\python. Move the pymel folder (the one with pymel.conf directly below it) into C:\My Documents\python so that it lives at ``C:\My Documents\python\pymel. Then add this line to your Maya.env:
PYTHONPATH = C:\My Documents\python
Setting up your python paths at the system level on OSX and Linux is a little bit involved. I will focus on OSX here, because Linux users tend to be more technical.
When you open a terminal on OSX ( /Applications/Utilites/Terminal.app ), your shell may be using one of several different scripting languages. (You can easily tell which is being used by looking at the label on the top bar of the terminal window, or the name of the tab, if you have more than one open. ) It will most likely say “bash”, which is the default, so that is what I will explain here.
To set up python at the system level using bash, first create a new file called .profile in your home directory ( usually something like /Users/yourname and denoted in a shell with the shortcut ~/ ). Inside this file paste the following, being sure to set the desired Maya version:
export PYTHONDEV=~/dev/python
export MAYA_LOCATION=/Applications/Autodesk/maya2009/Maya.app/Contents
export PATH=$MAYA_LOCATION/bin:$PATH
export PYTHONPATH=$PYTHONPATH:$PYTHONDEV
Here’s a line-by-line breakdown of what you just did:
set your custom python directory. You can change this to whatever you want, but if you are not using the Easy Install method make sure your pymel directory is immediately below this path (The variable PYTHONDEV does not have a special meaning to python or maya: we’re creating it so that we can reuse its value in the next few lines).
set MAYA_LOCATION, a special Maya environment variable that helps Maya determine which version to use when working via the command line ( be sure to point it to the correct Maya version).
the PATH environment variable is a list of paths that will be searched for executables. By adding $MAYA_LOCATION/bin you to access all the executables in the Maya bin directory from a shell without using the full path. For example, you can launch Maya by typing maya, or open a Maya python interpreter by typing mayapy.
If you manually installed pymel and ipymel, include the path to the directory where the ipymel script resides. For example, the line might look like the following:
export PATH=$MAYA_LOCATION/bin:$PYTHONDEV/pymel/tools/bin:$PATHset the PYTHONPATH to ensure that python will see your python dev directory, where PyMEL resides.
Open the Start Menu, right-click on “My Computer” and then click on “Properties”. This will open the “System Properties” window.
Changed to the “Advanced” tab, then click on the “Environment Variables” button at the bottom.
In the new window that pops up, search through your “User Varaibles” on top and your “System Variables” on the bottom, looking to see if the PYTHONPATH variable is set anywhere.
If it is not set, make a new variable for either your user or the system (if you have permission). Use PYTHONPATH for the name and for the the value use the directory above the pymel directory. So, for example, if the pymel directory is C:\My Documents\python\pymel copy and paste in the value C:\My Documents\python from an explorer window.
If PYTHONPATH is already set, select it and click “Edit”. This value is a list of paths separated by semi-colons. Scroll to the end of the value and add a semi-colon ( ; ) and after this add the directory above the pymel directory to the end of the existing path. For example, let’s say the starting value is:
C:\Python25\libIf the pymel directory is C:\My Documents\python\pymel, the edited value would be:
C:\Python25\lib;C:\My Documents\pythonAdd and set your MAYA_LOCATION. For example, for 2008 it would be:
C:\Program Files\Autodesk\Maya2008Next, find and edit your PATH variable. Append the following to the end of the existing value:
%MAYA_LOCATION%\binDon’t forget to put a semi-colon (;) between the existing paths and the new ones that you are adding.
If installing ipymel include the path to your ipymel bin directory. For example, if you manually installed PyMEL, the line should look like the following:
%MAYA_LOCATION%\bin;C:\My Documents\python\pymel\tools\bin
ipymel is an extension of the ultra-customizable IPython interpreter, which enables it to easily work with mayapy and PyMEL. It adds tab completion of maya depend nodes, dag nodes, and attributes, as well as automatic import of PyMEL at startup. Many more features to come.
As of version 0.9.2 ipymel is automatically installed when “easy” installing PyMEL, but you may have to do a few extra steps to get it working properly on Windows.
To Run: In a new shell, run the following command:
ipymel
Note
The “easy” installation method produces an invalid ipymel.exe on 64-bit windows systems. As of this writing I’m still looking into this.
Note
Though not a requirement for ipymel to work, it’s best to read up on Setting Up Your System Environment
Follow the installation instructions above for Setting Up Your System Environment
Install IPython. For a manual install, I recommend downloading the tarball, not the egg file. Unzip the tar.gz and put the sub-directory named IPython somewhere on your PYTHONPATH, or just put it directly into your python site-packages directory
Open a terminal and run:
chmod 777 `which ipymel`then run:
ipymel
Follow the installation instructions above for Setting Up Your System Environment
Install python for windows, if you have not already.
Install IPython using their windows installer. The installer will most likely not find the maya python install, so install IPython to your system Python instead (from step 1).
Install pyreadline for windows, also from the IPython website
Copy the IPython directory, pyreadline directory, and all the pyreadline.* files from your system site-packages directory ( ex. C:\Python25\Lib\site-packages ) to your Maya site-packages directory ( ex. C:\Program Files\Autodesk\Maya2008\Python\lib\site-packages ).
open a command prompt ( go to Start menu, then click ‘Run...’, then enter cmd ). Once it is open execute the following line to start ipymel:
ipymel.bat
If you encounter an error installing on linux, you may have to fix a few symlinks. Here’s how you check. cd to the directory where you unzipped pymel (you should be in the same directory where setup.py is). start up maya’s standalone interpreter by typing mayapy (or provide the full path to mayapy script if you do not have Maya’s bin directory on your PATH) at the prompt. now import setup.py as a module and run one of it’s tests:
import setup
setup.test_dynload_modules()
This will print out any compiled modules that do not work on your platform. This occurs because the flavor and/or distribution of Linux that you are running has different versions of certain system libraries than the one that Maya was compiled on. The easiest way to fix the problem is to create symbolic links from your existing libraries to those that Maya expects to find.
For example, in my case hashlib won’t import because it can’t find libssl.so.4. So, since I’m on a 64-bit version of linux, I check my /lib64/ ( on a 32 bit OS, check /lib/ )
cd /lib64
ls -la libssl*
I see the following returned:
-rwxr-xr-x 1 root root 302552 Nov 30 2006 libssl.so.0.9.8b
lrwxrwxrwx 1 root root 16 Jul 16 2007 libssl.so.6 -> libssl.so.0.9.8b
In my case, Maya expects libssl.so.4, but instead I have libssl.so.0.9.8b and a symbolic link libssl.so.6 pointing to libssl.so.0.9.8b. So, I have to create a symbolic link from the real library to the missing library:
sudo ln -s libssl.so.0.9.8b libssl.so.4
I’ve found that the same thing must sometimes be done for libcrypto as well.
Next, to avoid having to import pymel every time you startup, you can create a userSetup.mel file, place it in your Maya scipts directory and add this line:
python("from pymel import *");
Alternately, you can create a userSetup.py file and add the line:
from pymel import *
PyMEL includes a replacement for the script editor window that provides the option to translate all mel history into python. Currently this feature is beta and works only in versions beginning with Maya 8.5 SP1.
Warning
this feature is still considered experimental
The script editor is comprised of two files located in the pymel/tools/scriptEditor directory: scriptEditorPanel.mel and pymelScrollFieldReporter.py.
- Place the mel file into your scripts directory, and the python file into your Maya plugins directory.
- Open Maya, go-to Window –> Settings/Preferences –> Plug-in Manager and load pymelScrollFieldReporter. Be sure to also check “Auto Load” for this plugin.
- Next, open the Script Editor and go to History –> History Output –> Convert Mel to Python. Now all output will be reported in python, regardless of whether the input is mel or python.