Whats the shortcut to Debug in PyDev using Eclipse - eclipse

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.

Related

VS Code Terminal Not Allowing Typing

My VS code terminal was working fine, until one day when I tried to work on a project, that was still open in VS code, my terminal didn't allow me to type any commands. I couldn't type anything. This is the screen that I get.
Okay, for those of you struggling with the same problem, I've managed to solve it by clicking on the drop-down menu that says powershell and changing it to cmd.
this happened to me and simply
close vs code
right click on it
run as administrator
open the terminal and it will work
this problem happened when I changed the default path of CMD
For me, I tried using Powershell/CMD/Bash and I was having errors/blank terminal. I found typing echo hello and pressing CTRL + C made it appear. So in fact, everything was working, my terminal was just blank/glitched out, but was really accepting input.
I had a similar issue when running ionic serve command which runs the development server on the localhost. I paid attention after executing the command above, and it said:
Use Ctrl+C to quit this process
Pressing Ctrl+C then displays:
Terminate batch job (Y/N)?
Type Y or y
then the command prompt is shown again!
Here is a sample terminal window - trimmed for brevity:
For who has this problem using React. This happens when you start a live version using npm start. The terminal that handles the live version of the app cannot be used for anything else.
So to continue using the terminal you need to open a new terminal to use in parallel. To do so just click on the plus icon in the top right corner of the terminal panel then choose the "Power Shell" option. This will open a new terminal without restarting visual studio.
In Mac, when working with Python, this helped me: instead of clicking on the "Run Code" option, click on "Run Python file", in the right corner.
For Ubuntu users this is solved by this solution:
File -> Preferences -> Setting -> Features -> Terminal -> Inherit Env
I found two vscode on my desktop, I opened the other one and it worked. Looks like I updated it but the older one didn't disappear.
If typing Ctrl+C can help to get out of this frozen state, that will be easier to do with VSCode 1.64 (Jan. 2022)
The terminal can type the answer for you.
Terminal -- Auto-reply
The terminal is now able to automatically reply when a specific sequences of characters is received.
A good example of where this is useful, which is also the only default case, is the Windows batch script message Terminate batch job (Y/N)? after hitting Ctrl+C when running a batch script.
This typically just ends up causing problems for the user.
The terminal will now automatically reply with Y and enter (\r) which makes Ctrl+C in Windows feel much better.
Pressing Ctrl+C will immediately reply to the question and return to the prompt:
Theme: Sapphire
The feature was made generically so you can setup custom replies for other thing, just be careful when doing this as you are sending text to the process automatically.
For example you could use it to automatically update Oh My Zsh when prompted:
"terminal.integrated.autoReplies": {
"[Oh My Zsh] Would you like to check for updates? [Y/n]": "Y\r"
}
If you use Clink and enable their similar feature, you can disable it in Clink or in VS Code by setting the reply to null to avoid the two features conflicting with each other:
"terminal.integrated.autoReplies": {
"Terminate batch job (Y/N)": null
}
Go to terminal, preferences, settings.
Check "run code in terminal"
Restart VS.
I changed from bash to powershell in terminal first but the command prompt still not shown.
Then I navigate to File -> Perferences -> Settings and it starts working (command prompt shown)
This seems to just be a display problem. It happened to me when I changed my display settings for desktop icon and app scaling settings.
I managed to fix the problem by simply restarting my computer and re-opening VS code
I had the same problem ... In my case just run vs-code as administrator and works

Eclipse Run not asking how to run as, and opens wrong file

I'm brand new to learning Python and am using Eclipse to go through a Python course. When I first started doing exercises in Eclipse, every time I opened a file from the course examples, the first time I ran it I would click the green "run" button, and it would ask me how I wanted to launch the file (as Python Run or Python Unit Test). Somewhere along the way it stopped doing that and now if I open a file that has never been run before, when I click the green run button, it just runs a different file. I can click through the drop down menus to run as and select python module and then the run button works fine any time I use that file, but I can't figure out why it won't just run new files the way that it did when I first installed eclipse.
You probably have configured to run the last file... (PyDev asks if you want to do that in a dialog and does that for you if you confirm). Still, don't worry, this is probably for the best anyways as you can just hit F9 to run your file directly without clicking anything (and Ctrl+F11 or clicking the run should now re-run the last launch you did).
Make sure you take some minutes to read http://www.pydev.org/manual_101_run.html for tips on the best way to run Python modules from PyDev.

Ipython in pydev interactive debugging console(eclipse)

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).

Strange behaviour of created *.exe

Has anyone any idea why the resulting exe from a build comes with a console?
I've built an EXE and it shows up with the window it should (the right one), and a console window (the left one - obviously).
alt text http://img216.imageshack.us/img216/570/strangep.jpg
This behaviour is the same for the debug - exe and the release - exe.
When I start it from Eclipse the console window does not show up.
(Eclipse Galileo / MinGW / C)
Find the linker settings, and add the -mwindows switch.
you might look into this here surely answers why Eclipse is not opening your console window
There seems to be no way to get a java.io.Console object when running an application through Eclipse. A command-line console window is not opened with the application, as it is run as a background process (background to Eclipse?). Currently, there is no Eclipse plugin to handle this issue, mainly due to the fact that java.io.Console is a final class.
All you can really do is test the returned Console object for null and proceed from there.
as far as your console window popping is concerned, you might be using System.console in the application
Hope this Helps

Eclipse - Running programs not in the native eclipse console

I'm currently writing some ncurses code and the native Eclipse (3.2.2) console can't display its graphics. I'd instead like to run the program through xterm. What I want is to be able to start xterm and run from there. I'd prefer to not get involved with any plugins or that jazz. Just something simple.
EDIT
So I have the answer and it was pretty simple...
Run -> External Tools -> External Tools -> New Launch Config...
Then select location of your terminal emulator. /usr/bin/gnome-terminal in my case.
after that set the appropriate arguments. "-e ~/ncurses/start" in my case.
Then make sure you aren't allocating a console by unchecking that option in the "Common" tab.
Annon add to his question:
its a pain to keep switching back and forth from eclipse and the terminal. I'm looking for a way to just hit something like"F5" and have it run my ncurses program in a new xterm terminal process
The simplest way to do that is to report the command line into an external tool configuration, and point eclipse to use a shell (like described in this program)
In the argument, you will add the command line eclipse execute (command line which can be retrieved as mentioned in the second part of this answer below).
Of course, replace 'cmd.exe' by the shell of your choice, and try not setting the 'Allocate Console' checkbox in the Common tab of that external launcher.
To launch through a xterm, without eclipse involved (not what you are asking for, just keep here for archive)
You can launch your program through Eclipse (Run Configurations), and observe through a 'ps' command the exact Java command line used.
Or launch it in debug mode, and right click the task in Debug view and open Properties. It will show the command line, as documented here.
Then launch that command line directly in your console (Eclipse being not involved at all at this point).