I would like to F11 a python file in Eclipse and when I hit a breakpoint automatically enter the Python Interactive Console (not the default pydev debug console).
I understand that I could upon entering debug mode open a new interactive python console (I have turned on the connection between the interactive console and the debug console) and work from there. But not only is that an extra step but it is frustrating because everytime I interact with such an interactive console it shoves me back to the debug console! Then I have to go review the interactive console. I also understand that I could do a 'runfile' from within the interactive console, but I really want to use the convenient F11 capacity of eclipse to just be in an editor, hit F11 and when I break enter the interactive console.
Basically I would like the Interactive Console to be my debug console. Possible?
If the F11 approach is not possible, is there another approach? My goal is to get my history of command typing available to me with arrow keys. Not possible in the default python debug console from what I can tell. Perhaps if I made the pydev debug console ipython?
Thanks, I have searched a lot on this but can't come up with a solution.
from PyDev 3.9.2 onwards, a console prompt with history, code-completion, etc. will appear automatically.
See: http://pydev.blogspot.com.br/2015/02/pydev-392-released.html for details.
Related
I'm new to coding Python in VSCode. Previously I used Spyder but decided to move to VSCode as the project management seems better in it (I could easily switch to other files/folders by clicking on the path, just like in PyCharm). But I really need this one workflow which I still have not managed to do it in VSCode.
write some codes like Selenium.
Click run (F5)
The selenium browser opens up.
I could use the Ipython terminal to access the code interactively (find the element in the browser etc) and send new command.
I would like to have this workflow in VSCode. Im also quite overwhelmed by the difference in these 2 IDEs, for example, in VSCode, you have integrated terminal, a debugging console and an output tab, while im used to have only one-for-all Ipython tab.
Ok, I figured out what I need. Basically I just need to right click on the python file that I want to run on the side bar. Then I have to select 'run current file in interactive window'. The only difference is on the Ipython console, I have to use shift+Enter to send my input instead of just clicking enter. But its not a big deal.
How can I run code in the Interactive Console in PyDev and see the created variables in the Variables view?
I am looking for the same functionality available in Spyder. If I am interactively running a script or just testing pieces, I would like o be able to see all the available shell variables and their respective values in the variables view.
I have already checked "Connect console to Debug Session" in Preferences > Pydev > Interactive console.
But when I run, say, a=1, the "Variables" view will be in italic for a moment and nothing appears there.
ANSWER
Following Fabio's advice: I updated Pydev from v5.4 to 5.8. That did it.
Not sure what's happening there.
For me, after checking Connect console to Debug Session in Preferences > PyDev > Interactive console, I do see created variables in the variables view.
Are you actually using the interactive console (i.e.: started with Ctrl+Alt+Enter)?
Can you show a screenshot with Eclipse on that situation?
Which PyDev version are you using?
I have ipython working in pydev when using the normal interactive console, however when entering debug mode the console reverts to the standard pydev console. If I close this console and re-open it, ipython returns and I can use it as normal. Am I missing something, or is this a bug?
-Eric
Actually since PyDev version 3.0 you can attache a IPython console to a debug-session:
http://pydev.org/manual_adv_interactive_console.html#full-debug-support-in-interactive-console
To enable that feature, go to window > preferences > PyDev > Interactive Console and check 'Connect console to Debug Session?'.
Then only hassle is that you have to re-open a new IPython-console every time you re-launch the program in debug-mode.
Actually, Eclipse itself can have multiple consoles open at the same time... if you want, you can create multiple console views and pin a different console to each view (if you don't pin the console, one console will be shown on top of the other and you'll have to do the switching from one to the other manually).
As it is now, the debug console is not the same as the interactive console (it's a simpler version because of issues with the eclipse integration, although there are plans to be able to attach an interactive console to a debug session).
So, what you described is what should really happen (not really a bug).
The shortcut key is F11 to start debugging. But issue is that I have to be on that file and then hit F11 to start debugging.
Eg.
my file to launch the application is "launch.py" and "example.py".
example.py is open in the editor whereas launch.py is not.
Now, if I hit F11 it will try to launch the application using "example.py" and terminates due to error (as expected).
So then I have to open the "launch.py" in the editor and then hit F11 to start debugging the application.
Is there any neater way to configure the debugging, so that it starts the application in single hit/key?
Edit: example.py is some other file (some module). It does not launch the application.
As this PyDev Eclipse Tutorial suggests:
After the first run, if you type Ctrl+F11, the last file ran is re-run. Or, if you type just F11, a debug session is started with your last run. Let's test this...
Note: This behavior changed in Eclipse 3.3 -- but it's generally recommended to restore it in the preferences at: window > preferences > Run/Debug > Launching and set the Launch Operation to Always launch the previously launched application.
This tutorial will always consider this as the default option.
So, did you have this option selected?
If you have launch at least once launch.py, then you can re-launch it easily.
Although this isn't strictly an answer to what was asked initially, it might help someone looking here that had the same problem as me...
I'm a Java developer mainly, so have the Java view open almost all the time. However, sometimes I want to run some python file to test something (or just create a quick python script, and run it)...
In the Java editor, if the current class has a main(String[] args) method, I run it with (and popup the dialog to ask me what exactly I'd like to run in the middle)
alt+shift+x, j
Unfortunately, that doesn't work in the Python view, and I've not found a similar solution - it just asks me if I'd like to run it as a Java app... however, as the VonC says, you can run the last run thing (provided you've set the preferences accordingly) with
ctrl+f11
and this seems work well with python run configurations too.
But... What if the last thing I ran was a Java program, but I now want to run the active .py file? Previously, to run the .py file, I'd have to go digging through the buttons on the toolbar with the mouse, and I tend to prefer keyboard shortcuts...
Solution! So, finally I come to the actual useful bit of this answer - I just discovered by accident (typing Ivan's suggested shortcut, but missing!), it appears that
f9
will run the currently active python file.
Hope that helps someone get just that little bit faster...
I use CTRL+SHIFT+F9 to relaunch the previous debug configuration in Pydev.
Is there a way how I can access gdb's console in Eclipse? I would like to just be able to set breakpoints with the mouse and then use the console for debugging.
You must click here
Next select one with *gdb
Now you can write GDB commands in console example:
First of all, you need to install CDT plugin. Then, you can debug C++ application like Java application in Eclipse.
If you want gdb console, push 'Display Selected Console' in Console view in Debug perspective.
You can choose '[Your App name][C/C++ Application]gdb' entry, and then you can type gdb instruction(i.e. print this) in Console View.
It is possible to write in the console window and gdb answers. (You have to choose the right console window from the chooser in the top right edge of the console view).
Unfortunately the console is quite limited: gdb answers to command, but important features like tab-completion do not work.
Window > Show view > "Debugger Console" is the right way as of Eclipse CDT 4.7.0.
You can then type certain commands like print on the console and they will be evaluated.
Other more "active" commands like continue have no effect however.
Mentioned on this comment.