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

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.

Related

Old code runs every time I run the program

I just installed netbeans 12.0 again (I formatted my computer previously), I was customizing it but now every time I make a code I have to click on the Clean And Build Project button before clicking on the Run button, which is quite a lot. tired and takes time, when that should be automatic.
For example: I create a System.out.println ("Hello"); , I run the program and nothing appears on the console, I click the Clean And Build button and now it appear on the console; I change the message from "Hello" to "How are you?", I run the program and the "Hello" that I had written previously appears, that is, the application continues executing the previous code until I click Clean And Build. How can i solve this? Greetings.
Follow the below steps.
Note:Make sure your project haven't any errors.
Go to the project Explorer.
Right click on your project.
Select Clean (Now your code will clean).
After the clean build your project.
Then you can run your project.It should be ok

What settings do I have to change to make Visual Studio Code automatically run files in the right directory?

Coming from IDLE, I am used to be able to just left-click python files anywhere, it'll launch IDLE, and then pressing F5 just runs the script. In VSCode however, I have to open the terminal, cd into the right directory, and only then can I finally run my python script. Is there a way to change this behavior?
I was recommended to use the Code Runner extention and bound the Run Code (code-runner.run) command to my F5 key.
Then I noticed input() not being ran so I had to make sure code-runner.runInTerminal was on, but that re-started my problem from the beginning because the terminal was at the wrong working directory and then I finally found the code-runner.fileDirectoryAsCwd setting to run it from there.
I think this solution is similar to this one for the python extention, but I'm not sure if that would cause the whole wrong working directory issue again.
choose from menu file then click on auto save

"lein ring uberwar" just hanging there

I'm trying to figure out how to create uberwar from Clojure Ring and Compojure application in Eclipse Mars with Counterclockwise on Windows.
I'm following this tutorial, and I'm basically doing this:
in package explorer, I right click and create new Clojure project
right click newly created project, Leiningen, Generic Leiningen Command Line, enter lein new compojure-app gae-app-demo as per tutorial
this creates the Hello World app which I can run locally without any problems
then I go on and in the same way as in step 2 run lein ring uberwar
This starts new Console window which doesn't output anything and basically hangs until I manually stop it. It doesn't output anything, it doesn't report any errors, and it doesn't create war in target folder.
I've checked several other tutorials and I didn't find anybody having problems with creating uberwar. Where can I start debugging this, am I doing something wrong? This is one of the basic things one needs to do with every Ring/Compjure application, so it should be something simple I'm missing I hope.
Can you use terminal and type lein ring uberwar in the same directory in which is your project?
When you do step 1, you create a generic project, with CCW using leiningen in the background. With step 2, you create another project inside, using the lein new command. I don't think this is what you want.
Since you want it all from Eclipse/CCW, the first thing is to get the latest version (0.34.0 as I write) and install it (instructions: http://doc.ccw-ide.org/documentation.html#install-as-standalone-product).
Use the wizard to create your project, but change the text default in the Leiningen template field with compojure-app. Wait a few secs after hitting enter, as leiningen will download your deps.
Open project.clj. Right-click for the menu and select Leiningen | Generic Leiningen Command Line (or Alt+L then L), to open the lein prompt.
Type uberjar (this replaces <task> at the prompt) then hit enter. Wait a few secs and watch the status of the jar being built in the console tab.
Hope this helps.

Plugin to switch run configuration quickly in eclipse

Is there a plugin which can help to switch run configuration quickly in eclipse?
I am trying to learn django with practice a Eclipse with PyDev. I am follwing this page. This page frequently need to supply different parameters to manage.py, for example:
If you're interested, also run the following commands:
python manage.py validate -- Checks for any errors in the
construction of your models.
python manage.py sqlcustom polls -- Outputs any custom SQL
statements (such as table modifications or constraints) that are
defined for the application.
python manage.py sqlclear polls -- Outputs the necessary DROP
TABLE statements for this app, according to which tables already exist
in your database (if any).
To follow the tutorial, I will need to click the triangle next to the run button , then click "Run Configurations..", then select "Arguments" tab. Modify the argument, press "Apply", then press "Run".
I don't want to repeat each step to have different parameters. Is there other way to do it quickly? Maybe a plugin?
I am not sure if this is the right place to ask, if not, please help to move it to proper place.
Actually, for Django, the PyDev integration should have what you want builtin...
The steps on http://pydev.org/manual_adv_django.html should be more complete, but mainly you have to configure your project as Django and then in any PyDev editor you can do
Ctrl+2 dj (and then press enter)
to open a dialog to choose which django command to run.
Or you may enter the command directly there... i.e.:
Ctrl+2 dj syncdb (when pressing enter syncdb will be run directly)
-- note that it'll use the manage.py configured in the project to which the editor is related to run the command (so, the opened editor must be an editor from the project).
Another option would be right clicking the project and selecting the option under the 'Django menu'.
p.s.: If in some occasion you really had to change the command line all the time, the ${string_prompt} variable could help you -- although other variables in the run configuration could be more suited depending on your use case.
p.s.2: I think you could rename this question to note that what you want is related to running the django manage.py in PyDev (if that's really your use case).
Eclipse Runner could do this for you.

Whats the shortcut to Debug in PyDev using 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.