Results 1 to 18 of 18

Thread: Setting up PyCharm for use with Maya 2013

  1. #1
    Technical Animator csa3d's Avatar
    Join Date
    Sep 2008
    Location
    Dallas, TX
    Posts
    39

    Default Setting up PyCharm for use with Maya 2013



    All,

    I wanted to post some instructions on how to get PyCharm auto-completing and remote debugging code with Maya 2013. Since everyone's work environment is slightly different, note that there's probably a few different ways to get this done. The following is how my stuff is currently set up:

    Code:
    =================================
    PyCharm 2.6.2 Setup for Maya 2013
    =================================
    
    Prerequisites:
    --------------
    
        * Your OS is windows 7 (Assumed to be x64)
        * Download and install PyCharm:  http://www.jetbrains.com/pycharm/download/
        * AutoDesk Maya is installed
        
    Instructions:
    -------------
    
        1. Create a symbolic link to mayapy.exe
        
            * Open a command prompt with admin rights:
                Start > All Programs > Accessories > right click on Command Prompt > Run as Administrator > Click [Yes] at UAC Dialog popup
                
            * Navigate to Maya's bin directory:
                cd "c:\Program Files\Autodesk\Maya2013\bin"
            
            * Make a symbolic link from mayapy.exe to python.exe (This essentially creates a renamed exe shortcut)
              You should see, "sybmolic link created for python.exe <<==>> mayapy.exe" if successful:
                mklink python.exe mayapy.exe
              
        2. Configure PyCharm Maya Interpreter
        
            * Open PyCharm
            
            * Open the settings window
                File -> Settings...
                
            * Add our python.exe symlink as a python interpreter:
                * Navigate to Settings > Template Project Settings > Project Interpreter > Python Interpreter
                * click the [Add] button (plus icon) on the top far right
                * select "Local..." from the Select Interpreter Path dialog
                * select our "python.exe" symlink found at "C:\Program Files\Autodesk\Maya2013\bin\python.exe" from the selection dialog
                * hit the [OK] button and wait while PyCharm updates skeletons
                
                Leave this window up, don't close it!
            
            * Configure the Paths for our newly added interpreter:
                * With our newly added interpreter selected in the top pane, click on the _Paths_ tab in the bottom pane of the Python Interpreters window
                * Add path to AutoDesk provided stub files (This seemed to fix completion issues I was having):
                    * Click the [Add] button (plus icon) on the top right of the _Paths_ pane
                    * Navigate to and select "C:\Program Files\Autodesk\Maya2013\devkit\other\pymel\extras\completion\py" then click [OK] button
                * Remove Maya's site-packages entry (only if you added the stubs outlined above)
                    * Select the entry for "C:\Program Files\Autodesk\Maya2013\Python\Lib\site-packages"
                    * Click the [Remove] button (minus icon)
                * Add path Jetbrains Helpers (for remote debugging)
                    * Click the [Add] button (plus icon) on the top right of the _Paths_ pane
                    * Navigate to and select "C:\Program Files (x86)\JetBrains\PyCharm 2.6.2\helpers" then click [OK] button
                * OPTIONAL: Add any other sys paths you wish to incorporate here using same add steps as above
            
            * Close PyCharm and Reopen it for paths to take affect
            
        3. Configure PyCharm Maya remote debugger
        
            * From the Run menu of PyCharm choose "Edit Configurations..."
            
            * Configure the Unnamed debugger which appears as follows:
            
                * Change Name field from "Unnamed" to "Maya 2013"  (This value names the debugging process, feel free to choose any name)
                * Change port from "0" to "7720"  (This number determines the port which traffics communication, feel free to use another port)
                * Check [x] Check no other instances are running
                * OPTIONAL:  Uncheck [ ] Redirect output to console  (to prevent output redirection from Maya)
                * OPTIONAL:  Uncheck [ ] Suspend after connect  (to only pause at a breakpoint)
                
                Note: settings in this window affect the code necessary to trip the remote debugger, displayed in sections 2 and 3.  Be sure
                      to write it down (or re-open this configuration window later to retrieve it later)
                      
        4. Remote Debugging from Maya
        
            * In PyCharm:
                * Select the "Maya 2013" Remote Debug profile from the Run/Debug dropdown just below the main menubar
                * Click the green debug icon next to the dropdown to start PyCharm's server
                * You will see a debug console appear below the main code window indicating the server is awaiting a connection
                * Load the code you wish to step through, and ensure there's a breakpoint set somewhere within the code
                * Paste the server configuration code from step 3's note into your code somewhere before your breakpoint and save the file.
                
            * In Maya:
                * Ensure that "C:\Program Files (x86)\JetBrains\PyCharm 2.6.2\helpers" is part of your sys.path  (there are numerous ways to do this)
                
                    pydev_path = r'C:\Program Files (x86)\JetBrains\PyCharm 2.6.2\helpers'
                    if not pydev_path in sys.path:
                        sys.path.append(pydev_path)
                
                * Import your and execute the code to remote debug.  If all goes well, PyCharm should hold the code at your breakpoint, allowing
                  you to navigate the code using the bottom Debugger pane
    Here's some images to go along with these instructions. At some point, I'll put these on my site in a more organized manner. Hope they help:


































    -csa

  2. #2
    for loop mattanimation's Avatar
    Join Date
    Jul 2010
    Location
    Mesa, AZ
    Posts
    202

    Default

    Thanks! If I ever get the cash to get pyCharm I will definitely use this.

  3. #3
    while loop
    Join Date
    Feb 2009
    Location
    Copenhagen
    Posts
    169

    Default

    Based on a glowing recommendation, I got ahead of myself and purchased a copy of PyCharm.. without testing it with Maya first naturally.

    I've then followed this guide to the letter on a few different machines, in Maya 2013 x64/2013.5 x64 and using a range of different ports. For remote debugging every time I try to connect, Maya just hangs indefinitely. Did anyone run into this? Found a fix?

    This along with the Copy/paste thing, has me itching to just boot up wing, but I feel I should somehow get my moneys worth :-)

    I'm on PyCharm 2.7.3

    Cheers,
    Sune

  4. #4
    while loop
    Join Date
    Feb 2009
    Location
    Copenhagen
    Posts
    169

    Default

    Here is a capture of my setup attempt:

    http://www.youtube.com/watch?v=8xQwgen3N2A

  5. #5
    integer Jredd's Avatar
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    36

    Default

    I must be missing something because my bin folder does not contain the python.exe file :/

  6. #6
    while loop
    Join Date
    Feb 2009
    Location
    Copenhagen
    Posts
    169

    Default

    Quote Originally Posted by Jredd View Post
    I must be missing something because my bin folder does not contain the python.exe file :/
    It's in step one of the guide, making a symbolic link.

  7. #7
    while loop
    Join Date
    Feb 2009
    Location
    Copenhagen
    Posts
    169

    Default

    I've tried remote debugging Maya/MotionBuilder on a few computers now. As it works a "Charm" on some, but not at all on others, I'm thinking my troubles are down to Security Software getting in the way of remote debug. I'm going to call IT and will hopefully have it working in about 6 months :-)
    Last edited by Sune; 07-05-2013 at 08:30 AM.

  8. #8
    while loop
    Join Date
    Feb 2009
    Location
    Copenhagen
    Posts
    169

    Default

    3 month in and still no solution from IT (see I told you). However something must have changed (I did change to the same port as wing debug works on), so now stuff works.. Not going to look further into it why now, just happy it works :-) I'm really (really) loving my PyCharm.
    Last edited by Sune; 10-04-2013 at 10:36 AM.

  9. #9
    Principal Artist
    Join Date
    Feb 2012
    Location
    Monroe, WA
    Posts
    2

    Default

    Quote Originally Posted by Sune View Post
    3 month in and still no solution from IT (see I told you). However something must have changed (I did change to the same port as wing debug works on), so now stuff works.. Not going to look further into it why now, just happy it works :-) I'm really (really) loving my PyCharm.
    Hi Sune,

    You mention MotionBuilder ... how did you handle it given that there is no mayapy.exe equivalent in MoBu?

    EDIT:

    Nevermind, figured things out.

    Just jumped straight down to the Debugger Configuration setup, configured it, and then made sure that MotionBuilder was using the pydev in PyCharm (e.g. adding this to the sys.path in Mobu: r"C:\Program Files (x86)\JetBrains\PyCharm 3.0\pycharm-debug.egg").
    Last edited by vsnappy; 10-06-2013 at 04:10 PM. Reason: update

  10. #10
    variable
    Join Date
    Nov 2008
    Location
    Sunnyvale, CA
    Posts
    16

    Default

    Hi csa3d. Thank you for your useful information.

    I'm trying to debug maya python using PyCharm3.0 pro by reading your great material. (I understand your info is for PyCharm2.6.2)
    I probably finished the above setup correctly. But when I execute my python file via Maya scripted editor like the last step, I encountered the following error...
    Of course, I already added some breakpoints into my python code on PyCharm3.0 pro.
    ---
    # ValueError: invalid literal for int() with base 10: 'c:/temp/test_debug.py'
    # line = int(line)
    # File "C:/temp/python/lib/pydev/pydevd.py", line 609, in processNetCommand
    # Traceback (most recent call last):
    # pydev debugger: warning: trying to add breakpoint to file that does not exist: python-line (will have no effect)
    # pydev debugger: Unable to find real location for: python-line
    ---

    Is there anyone who can debug maya python on PyCharm3.0 Pro?
    If so, I would like to know the some clue or tips to finish the setup for PyCharm3.0 Pro.

    According to the JetBrains offical announce, PyCharm3.0 already suports maya remote debug.
    But I can't find the tutorial or the documentation... Is there some official information ?
    http://confluence.jetbrains.com/disp...rm+3.0+Roadmap

    Thanks in advance.
    Last edited by dragonboy765; 10-12-2013 at 01:42 AM.

  11. #11
    integer Jredd's Avatar
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    36

    Default

    Quote Originally Posted by dragonboy765 View Post
    Hi csa3d. Thank you for your useful information.

    I'm trying to debug maya python using PyCharm3.0 pro by reading your great material. (I understand your info is for PyCharm2.6.2)
    I probably finished the above setup correctly. But when I execute my python file via Maya scripted editor like the last step, I encountered the following error...
    Of course, I already added some breakpoints into my python code on PyCharm3.0 pro.
    ---
    # ValueError: invalid literal for int() with base 10: 'c:/temp/test_debug.py'
    # line = int(line)
    # File "C:/temp/python/lib/pydev/pydevd.py", line 609, in processNetCommand
    # Traceback (most recent call last):
    # pydev debugger: warning: trying to add breakpoint to file that does not exist: python-line (will have no effect)
    # pydev debugger: Unable to find real location for: python-line
    ---

    Is there anyone who can debug maya python on PyCharm3.0 Pro?
    If so, I would like to know the some clue or tips to finish the setup for PyCharm3.0 Pro.

    According to the JetBrains offical announce, PyCharm3.0 already suports maya remote debug.
    But I can't find the tutorial or the documentation... Is there some official information ?
    http://confluence.jetbrains.com/disp...rm+3.0+Roadmap

    Thanks in advance.
    With pycharm 3.0 you no longer really need to follow this process for the most part. You can just point the interpreter to mayapy.exe in the bin folder and you should be good to go. This is how I currently have my project interpreter setup in pycharm
    Last edited by Jredd; 10-15-2013 at 05:49 PM.

  12. #12
    variable
    Join Date
    Nov 2008
    Location
    Sunnyvale, CA
    Posts
    16

    Default

    Hi Jredd. Thank you for your reply. But I don't understand your current situation. you mean, you already can do Maya remote debugging on PyCharm3.0?
    I asked the same question to Jetbrain which is the developer of Pycharm. However, they answered that "Maya support will be in a separate plugin that hasn't been released yet. sorry for the confusion". So I guess that we can't do the remote debugging on Pycharm3.0 since Jetbrain will release the separate plugin.
    https://twitter.com/pycharm/status/390206442005090304

    So I'm curious about the specific method to setup the remote debugging without the above plugin, if you can debug even now.
    Thanks in advance.
    Last edited by dragonboy765; 11-03-2013 at 01:13 PM.

  13. #13
    integer Jredd's Avatar
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    36

    Default

    Quote Originally Posted by dragonboy765 View Post
    Hi Jredd. Thank you for your reply. But I don't understand your current situation. you mean, you already can do Maya remote debugging on PyCharm3.0?
    I asked the same question to Jetbrain which is the developer of Pycharm. However, they answered that "Maya support will be in a separate plugin that hasn't been released yet. sorry for the confusion". So I guess that we can't do the remote debugging on Pycharm3.0 since Jetbrain will release the separate plugin.
    https://twitter.com/pycharm/status/390206442005090304

    So I'm curious about the specific method to setup the remote debugging without the above plugin, if you can debug even now.
    Thanks in advance.
    Ah dragon sorry I wasn't thinking when I posted last. Yes you can't debug with the current pycharm without doing the above methods but It's easier now to incorporate Maya's exe of python so you can easily call on Maya specific methods without having to jump through the loops you use to have to do in the above tutorial.

  14. #14
    noob Chris.Evans's Avatar
    Join Date
    Jul 2008
    Location
    Frankfurt am Main
    Posts
    63

    Default

    PyCharm peeps said this Maya functionality would be added in January this year, then they said with 3.1.. I still don't see this plugin, any news?

  15. #15
    program Theodox's Avatar
    Join Date
    Mar 2012
    Location
    Seattle
    Posts
    747

    Default

    [Thread bump]

    If you try to run unit tests in Pycharm using MayaPy as you're intepreter, the test runner fails because PyCharm wants to import the os module directly and it can't get at the copy of the OS module in <MAYA>/Lib/python27.zip .

    If you either unzip the library as in this example, or have a separate python install on your machine with the same version as your maya python, you can remove the path from your interpreter setup in pyCharm and then add a link to the location of your (unzipped) standard library:

    tweaked.jpg

    You should be able to run the tests etc no problem.

    Note that in the link above the guy is removing the zip file and the /Lib folder. In my example I was able to leave /Lib intact so the only substitution is the standard library location. There may be wierd interactions down the road - some packages use the location of os.py to figure out where the interpreter is, which is going to be wrong in this case - but I haven't seen anything yet.

  16. #16
    undefined
    Join Date
    Feb 2009
    Posts
    12

    Default

    Not having much luck with this, i can get it to connect but then get this:

    Code:
    import pydevd
    pydevd.settrace('localhost', port=7720, stdoutToServer=True, stderrToServer=True)
    # -------------------------------------------------------------------------------
    # pydev debugger: CRITICAL WARNING: This version of python seems to be incorrectly compiled (internal generated filenames are not absolute)
    # pydev debugger: The debugger may still function, but it will work slower and may miss breakpoints.
    # pydev debugger: Related bug: http://bugs.python.org/issue1666807
    # -------------------------------------------------------------------------------
    # pydev debugger: Unable to find real location for: C:\\Program Files (x86)\\JetBrains\\PyCharm 3.4.1\\pycharm-debug.egg\pydevd.py
    # pydev debugger: Unable to find real location for: C:\Program Files\Autodesk\Maya2014\bin\python27.zip\threading.py
    # pydev debugger: Unable to find real location for: C:\\Program Files (x86)\\JetBrains\\PyCharm 3.4.1\\pycharm-debug.egg\pydevd_additional_thread_info.py
    # pydev debugger: Unable to find real location for: C:\\Program Files (x86)\\JetBrains\\PyCharm 3.4.1\\pycharm-debug.egg\pydevd_comm.py
    # pydev debugger: Unable to find real location for: <maya console>
    # pydev debugger: Unable to find real location for: C:\\Program Files (x86)\\JetBrains\\PyCharm 3.4.1\\pycharm-debug.egg\pydevd_tracing.py
    I had to append 'C:\\Program Files (x86)\\JetBrains\\PyCharm 3.4.1\\pycharm-debug.egg' instead of /helpers to get this to work, because helpers just kept giving me a 'no module named pydevd' error...

  17. #17
    program Theodox's Avatar
    Join Date
    Mar 2012
    Location
    Seattle
    Posts
    747

    Default

    those messages are not exactly harmless but you should be able to work with them. Have you tried stepping through code with the connection on? The messages will only interfere with your ability to step into standard lib code or pydevd itself, which are rarely necessary

  18. #18

    Default

    I get the same errors plus a bunch of other messages when starting the debug connection and executing even simple one line scripts. until after failing on some openMaya packages (which I don't even import or do anything else with) it halts maya entirely until I disconnect pycharm.


    Capture.jpgc2.JPG

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •