Sublime Text 2 and Maya Setup Guide

sublime code intel

 

Sublime Text 2 is a really great text editor. If you haven’t tried it, do yourself a favor! Here is a guide to get you setup for Maya scripting. It includes auto complete for PyQt and maya.cmds/mel; and ctrl+enter communication with Maya. It took a bit of googling and fiddling to get this working, so hopefully I can save you some time and frustration.

 

1) First, get Sublime Text 2. It has an infinite trial period. If you like it, support it by buying it.

 

2) Get package control . Once its installed, press ctrl+shift+p in Sublime Text and start typing “package.” If you want, go to “Package Control:Discover Package” to browse the huge list of plugins.

 
3) UPDATE: I’m using Jedi now, its a much easier setup Here’s the github page, you can also install it through package control. Be sure to add to add ‘C:/Program Files/Autodesk/Maya[VERSION]/devkit/other/pymel/extras/completion/py/’ to the paths (see github for setup instructions)

3) Press ctrl+shift+p, start typing “package”, go to “Package Control:Install Package” and press enter. Now start typing “codeintel” and select “SublimeCodeIntel.” Let it install.

 

4) I had to remove some files from code intel to get it to work. The files were throwing errors so I just removed them and it worked. So go to “…\AppData\Roaming\Sublime Text 2\Packages\SublimeCodeIntel\libs\codeintel2” (You can easily navigate to this folder from Sublime Text 2 by selecting Preferences>Browse Packages) and take out “lang_css.py” and “lang_less.py” and their respective .pyc files.

 

5) Place pyqt4.cix in “…\AppData\Roaming\Sublime Text 2\Packages\SublimeCodeIntel\libs\codeintel2\catalogs” (You can easily navigate to this folder from Sublime Text 2 by selecting Preferences>Browse Packages). This .cix file is a catalog of pyqt for auto complete. I originally found it on wuub.net. In the version you can download here I changed one line to make it work. I edited the “name” attribute to the value “PyQt4”. All other cix files I found on the web didn’t work properly and using codeintel’s gencix.py utility created an incomplete cix. This does it right!

 

6) Navigate to “C:\Users\[WHATEVER]\Documents\.codeintel” and edit the config file to look like this (change the paths to fit your environment):
{
“Python”: {
“python”: ‘C:/Python26/python.exe’,
“pythonExtraPaths”: [
‘C:/Python26/Lib/site-packages’,
‘C:/Program Files/Autodesk/Maya2013/devkit/other/pymel/extras/completion/py/’
]
}
}

Note: The first time code intel tries to auto complete something, it will take a while. Especially the PyQt4.cix file. It may seem like its not working even after it completes loading, but try it a few times. Eventually if it really isn’t working, check out the log in “C:\Users\[WHATEVER]\Documents\.codeintel”

 

7)UPDATE: SublimeMaya is now in package control too. It shows proper stack trace and line number, so you can ignore this step. Now you need to get Sublime Text 2 to communicate with Maya. Get MayaSublime. In the plugin (which you can easily access from Sublime Text 2 via Preferences>Browse Packages), I edited the MayaSublime.py file so that it provides stack trace and the proper line number in the stack trace. You can download my version here. Thanks to Justin Israel for writing this. I also put cmds.commandPort(name=”:7002″, sourceType=”python”) in my userSetup.py script for convenience.

 

 

I hope this helps! If you have any additional things you’ve done with Sublime Text 2 to help with Maya development, let me know in the comments.

 

 

Comments

  1. Fingus says:

    Just a heads up if you’re using Maya 2016, Autodesk decided to remove the devkit folder so in order to get the python autocomplete files you need to download the devkit from Autodesk’s App Exchange.

    I butted my head against this for over an hour before I decided to check if there was something wrong with my install, and inside the devkit folder all I found was a file named README_DEVKIT_MOVED.txt

    Thanks autodesk!

  2. Torben says:

    Hi Danny.

    Thank you very much for this great tutorial. I got everything up and running except for ctrl-enter.. As far as I understand I should be able to press ctrl-enter to execute my script inside Maya. Can you please add explain how that is setup?

    Thanks again. Great tutorial 🙂

  3. jed bush says:

    for auto-completion, just install jedi, and in the Preferences > Package Settings > Jedi > Settings-User file, just enter this for whatever maya version you have:

    {
    // additional python package path list
    “python_package_paths”: [“C:/Program Files/Autodesk/Maya2016/devkit/other/pymel/extras/completion/py”],
    }

    It’s a bit different than what you see laced throughout the comments.

    no need to mess around with needing a project, and specifying project settings if you don’t need to.

    • Brilliant, this works perfectly.

      I’m sure others will be more intelligent but just in case:
      make sure you replace these quotation marks when you paste them into sublime text settings !

      The html formatted “” will cause an error in Sublime settings which took me an embarrassing amount of time to spot.

  4. Teresa says:

    Hello Danny,

    THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    You’ve made my night!

    Teresa

  5. Sam says:

    Hello,
    thanks for the tuto, i’am new to sublime and python so i’m a bit lost about this part :
    where do i have to do this ? in what file ?

    Be sure to add to add ‘C:/Program Files/Autodesk/Maya[VERSION]/devkit/other/pymel/extras/completion/py/’ to the paths

    Thanks you.

    • Danny Wynne says:

      the github page for jedi has more info under the “Python interpreter settings” section https://github.com/srusskih/SublimeJEDI

      to get to your project settings file, in sublime menu, go to Project>Edit Project

      • Eric says:

        After a day and a half, me too being a beginner in both python and Sublime Text 3 (in WINDOWS!), I was able to make it work with Danny’s comments. You should read all the comments below, but here is how I manage to make it work:

        1. After installing the JEDI package, you NEED to create a “PROJECT” template (Save project as…) that will conform to maya’s syntax. Preferences won’t work – I’ve tried everything. So, first step, I created a new Project named “MayaPython”

        2. Choose “Edit Project” to enter your Maya path / settings. Since I don’t have a standalone Python version installed on my computer, I used the Python interpreter that comes with maya (mayapy.exe). The rest is the same as Danny’s configuration, except that I use Maya 2013:

        {
        “settings”:
        {
        “python_interpreter_path”: “C:/Program Files/Autodesk/Maya2013/bin/mayapy.exe”,
        “python_package_paths”:
        [
        “C:/Program Files/Autodesk/Maya2013/devkit/other/pymel/extras/completion/py/”
        ]
        }
        }

        3. Save your Project. EVERY TIME you want to have auto-completion for maya’s commands, you need to start from this project. So I close all open windows and save again this “MayaPython.sublime-project”.

        4. Start a new file. Choose Python syntax. Here is the fun part… Auto-completion won’t work until you type “import maya.cmds as cmds” or “as xxxxx” anything you want. ha. ha. ha. This is the part that I have missed for about 20 hours. You should have auto-completion for maya’s commands now!! sooo cooool

        Thank you so much Danny : )

        I hope you don’t mind that I shared how it worked for me.

        • Eric says:

          p.s. I meant:

          Here is the fun part… Auto-completion won’t work until you type “import maya.cmds as cmds” …

          …and then press enter to send the command to sublime text and import the commands.

  6. Josh says:

    I followed the instructions on the Jedi setup, but I’m not getting auto completion yet. Here is what I have in my .sublime-project:

    {

    “settings”:
    [
    {
    “python_interpreter_path”: “C:/Python26”
    },

    {
    “python_package_paths”: “C:/rogram Files/Autodesk/Maya2013.5/devkit/other/pymel/extras/completion/py”
    }
    ]

    }

    Any ideas?

    • Danny Wynne says:

      looks like theres no P in “Program Files”

      you can go to %appdata% and find Jedi\Jedi\scripts. in this folder youll see your python version, you can delete the folder for your python version and it will create it again. In the python version folder, youll see jedi creating files, this means its working

      hope that helps

      • Josh says:

        Thanks for your reply Danny.

        I added the “P” back in. But still no dice.

        When I go to %appdata%, I don’t see a Jedi folder in that directory. If I go to the sublime folder in that directory, I can path to:
        Sublime Text 2\Packages\Jedi – Python autocompletion\jedi

        There is no “Jedi\Jedi\scripts” folder that I can find in %appdata%. Is this installed correctly?

        • Juan says:

          Here is what my Project file looks like and it works.

          
          {
          
              "settings": {
          
                  "python_interpreter_path": "C:/Python27/python.exe",
          
                  "python_package_paths": [
                      "C:/Program Files/Autodesk/Maya2014/devkit/other/pymel/extras/completion/py/"
                  ]
              }
          }
          

  7. Mariano says:

    Is there any plugin for sublime 3?

  8. stu says:

    big thanks

  9. jinei says:

    hello .thanks for the tutorial…with python works OK
    but not for Mel
    // Error: rehash; source “C:\PH\zeroFKControls.mel”; //
    // Error: Line 1.42: Cannot find file “C:PHzeroFKControls.mel” for source statement. //

    help please.

  10. Jorge says:

    Hey Danny, thank you for the working PyQt4.cix file and the guide, almost switched to Komodoedit for this.

  11. cedric says:

    Hi..

    I try the maya Sublim… even with your release, I still cannot see the maya output somewhere. Do you have any idea?
    the port is open, I replace with your file…I restart… no idea…

  12. Does the auto-completion also work with PyMEL?

  13. Chris Dardis says:

    Great tutorial!

    Just wanted to mention that the dev of SublimeCodeIntel seems pretty busy and has not kept the package in step 4 up to date. I was getting all sort of errors.

    the fix was to clone a read-only copy directly from github;

    git://github.com/Kronuz/SublimeCodeIntel.git

    Now no errors, and I did not have to remove lang_##.py files as described in step 4.

    Great Tute again man, thanks for the info!

  14. tringa says:

    Hi, thank you for the .cix file.
    I tried to create a .cix file by myself but keep getting errors. Here my source of informations ( http://community.activestate.com/forum/komodo-python-qt-and-pyqt-catalog-files-cix ).
    However thank you very much. 😉

    • Danny Wynne says:

      Yea I tried to generate a cix as well. Maybe you’re getting an error when gencixcore.py tries to get all the attrs and members for the objs. There’s a commented out line #attrs = inspect.getmembers(object, attrfilter), around line 238. Fiddle with that area.
      I fixed the errors eventually, but the resulting cix was thin, it didn’t have all the functions and stuff. It was a fraction of the size of the cix I link to. If you get it working right, let me know!

  15. Dan says:

    Hey Danny, great tutorial, thanks for taking the time to write it!

Leave a Reply

Your email address will not be published.