Debugging from the Python Console
I'm working on a tool that's invoked primarily from the command line and scripts. The easiest way for me to interact with it is through the console. So in PyCharm, this is fairly easy to do, just Tools->Run Python Console... Then I can work with my code directly in there as per normal.
The problem is that PyCharm doesn't really seem to get me anything over running from the regular Python console! I really want to be able to set a breakpoint in my code, so I could do something like this:
D:\Tools\Python27\pythonw.exe -u C:\Program Files (x86)\JetBrains\PyCharm 1.2.1\helpers\pydev\console\pydevconsole.py 52626 52627
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['C:\\Program Files (x86)\\JetBrains\\PyCharm 1.2.1\\helpers', 'D:\\Code\\Python\\PyHello'])
Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32
>>> from fibo import Fibo
>>> fib = Fibo(boundary=10)
>>> fib.show()
1
1
2
3
5
8
>>>
Pretty straightforward. But I'd like to set a breakpoint in the __init__ or show() functions and that doesn't work. Is there a way to start the console in debug mode?
I found this thread, but it's not quite what I want to do: that involves starting a debug session first, then opening the shell afterwards. I want to be able to debug from right within the console.
请先登录再写评论。
Hello Rick,
Right now there is no possibility to run the console in debug mode. Running
your script in the debugger, putting a breakpoint somewhere and then showing
the command line console is the only possibility at the moment.
>>>> from fibo import Fibo
>>>> fib = Fibo(boundary=10)
>>>> fib.show()
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Oh. Well, that'd be useful, so consider this a vote for that :-)
What I've done is to create a go.py script that contains the stuff I'd normally do in the console and then I run that. But it's OK, but not as flexible because of course I can't just try different things as I go along.
Thanks for the quick response.
Hi Rick,
There is already an issue for that http://youtrack.jetbrains.net/issue/PY-3057 so you can vote ;-)