External Python Debugger


#5

Oh, thanks for pointing me to the ‘Enable Frames’ option. I tried warping systems frames to get _getframe by using this module, but I wasn’t successful.

Now I switched on frames and pydevd works. :slight_smile:

Now I can write and debug a Rhino.Python script in Eclipse/PyDev.

Only two things a necessary:

  1. Add the path to the pydevd library. pydevd is located in /eclipse/plugins/org.python.pydev_[version]/pysrc/.

  2. Import pydevd and start the debug client at the point the debugging session should start in the script to be debugged:

    import pydevd; pydevd.settrace(port=678)

I didn’t do any in depth testes, but it seams to work just fine. Thanks.

See you
Flo


(Steve Baer) #6

Great! Could you provide some more instructions on how you did this? I’m not very fluent with pydev, but would love to be able to show this feature to other people.


#7

I tried to write a tutorial:

Remote Debugging Rhino.Python Scripts

Please let me know if theres something I can improve.

See you
Flo


#8

A brief update:

The whole thing does also work for a Python script inside the GhPython Gasshopper component, though break points do not work properly, but inspection and step into/over/… do work as expected.

GyPython is an open source Gasshopper component, the allows to include Python script in Grashopper definitions.

The source code is on GitHub: https://github.com/mcneel/ghpython/, a precompiled version is also on GitHub: https://github.com/mcneel/ghpython/downloads/

See you
Flo


(Steve Baer) #9

Thanks for writing this. I really need to set aside some time to try this since it would be really useful for a lot of people to know about.


#10

Hi!

I’ve followed Steve Baer tutorial about how to set-up eclipse to write rhinopython code (Rhinocommon and rhinoscriptsyntax) and now I’m setting-up Eclipse to debug code from ghPython and Rhino python editor.

I can debug perfectly python code from the Rhino script editor, but when I debug from Grasshopper, everything works, but I cannot see the code written in the GH component in the eclipse window, neither activate breakpoints into the code. Is there any way to specify to pydevd what code it should run and analyse from GH? I was thinking that could be possible to reference the python code from an external file into the ghpython component and tell pydevd that he have to use that file to debug.

Thanks in advance.
Cheers.

PS.: This is what I have debugging code used in GH component.


#11

Ok guys :slight_smile: SOLVED!

I established without knowing it a path to make pydevd look for source code. Removing the path now pydevd ask me to choose the code that I want to debug.

Cheers. :slight_smile:


(Steve Baer) #12

@piac and @alain you may be interested in seeing this post


#13

I’ve just create a tutorial about this process right here:

http://www.blurrypaths.com/post/84032300754/ghpython-and-eclipse-workflow-to-edit-and-debug-code

Sorry for my English butchering :stuck_out_tongue:


#14

Hi,
good to here you figured it out. Sorry that my tutorial didn’t make clear hat its necessary to import pydevd.

Nice tutorial, I’ll link to it from mine.

See you
Flo


(Giulio Piacentino) #15

Yes, I read Angel’s nice tutorial yesterday evening. It’s inspiring to see a new creative use for the code input parameter.

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#16

The question I have is - what about linking the “native” EditPythonScript editor to the GH Python component in a similar fashion - and hopefully simpler to set up - wish for V6…

(Or, I guess the full editor/debugger running inside the component would be even better…)

–Mitch


#17

Thanks @piac! I’m glad you like it :slight_smile: (adding you to the credits :P)

You are totally right @Helvetosaur, the process is a little bit tedious if you don’t have to edit long scripts inside ghPython component, but when you need it, there is not a lot of choices to pick from.

I totally agree with you @Helvetosaur , probably a seamless integration between editors is a nice way to go, but I have some suggestions if this happen, because the rhino.python editor is neither a perfect solution (no proper autocomplete, no linter, no proper outliner…)

Everytime I think about a perfect lightweight code editor, SublimeText comes to my mind: reliable, fast, lot of options to personalize your workflow ( custom code snippets, multiline selection, error linter via plugins, powerful autocomplete python API to create your extensions…) , and code edition tasks…it lacks of proper debugging options but the rest is just perfect to take as example of a good and lightweight code editor.


#18

The autocomplete for all rhinoscriptsyntax and RhinoCommom related stuff plus imported modules is pretty good IMO… I think the current editor is not bad for most “average” tasks and programming skills, at least at my level of operation, I don’t feel limited by it. I would like to see some additional features, though - most importantly code snippets as you mentioned…


#19

Yep! That’s true. What I mean by proper autocomplete is that it doesn’t track your code to offer you variables that you created before, functions or classes created in the document, etc…That stuff speed up the process of writting code a lot. That is because I said “proper” instead of “lack of”.


#20

Yep, you’re right about that! --Mitch


#21

While we’re at Rhino Python Editor autocomplete:
After assigning of a certain class or its method to a variable, autocomplete seems to stop working. An example:

spher = Rhino.Geometry.Sphere(pt, 2)
brep = spher.ToBrep()

Once the “dot” character has been typed after “brep = spher” autocomplete does not appear, so you would have to type the “ToBrep()” manually.

Also, most of the time I find myself not remembering the exact name of the module/method/function. Using substrings when autocompleting would be a big plus (like: “tb” for “ToBrep”).


What can McNeel do to improve your development?
(Alain Cormier) #22

Thanks for the great post Angel.

There is a lot of work to be done on improving the current editors and on simplifying remote debugging with 3rd party IDEs and we’re working on that. You all bring some great points.

Does debugging in ghPython work everytime for you? When I tried debugging rhino scripts using pydev and/or pycharm I couldn’t get it to work everytime (not sure why) but if I enabled “tracing” in addition to “frames” (I was using a custom Rhino Python plug-in that allowed me to enable tracing) then it would work everytime.

Cheers,
Alain


#23

Nope, as far as I’ve tested, it works properly all the time (+50 times from yesterday…).


#24

@frist @Alain Hi. I’m working on getting pydev work with rhino. But unfortunately I run into a problem.

I opened up a new topic for that specific problem. I hope you can help me.

Link: