Stop Spyder from opening the underlying file when in debug mode - python

I run my script in Spyder. It finds an error. I click the Stop button. Spyder will open the underlying python file that caused the error. How do I stop this from happening?
I have gone through the settings and google, but I cannot find out how to stop this.
What I want is when there is an error, I click the stop button, nothing further happens other than the code has exited debug mode.

You could disable that behavior by changing Run preferences:
Tools->Preferences
On left menu choose “Run” then locate “General settings” section then uncheck "Directly enter debugging when errors appear."
Apply
:)

Related

run python script in VS code works with run python file button, but not F5 key

I can run a python script by pressing the run python file button:
but unable to run the same when pressing the F5 key or run from the dropdown menu.
I can also run in the interactive window fine:
And likewise i can run a notebook fine.
other checks:
I can verify that it doesn't debug by adding a breakpoint and running.
Would there be a key-binding that is missing perhaps ?
What is causing this and how can one fix the issue please ?
It turns out that the error is a bug in the Python extension.
If you go to the Extensions tab, select the Python extension, then click on the little arrow next to Uninstall > Install Another Version... and install 2021.12.1559732655 the debugger should work again.
Here is the link to the fix: https://learn.microsoft.com/en-us/answers/questions/724858/vscode-debugger-not-working-for-python.html
In the meantime disable automatic updates to make it stick until they fix that.
To do this going to settings, typing python.terminal.activateEnvironment into the search bar and deactivating the checkbox.

Spyder 5.1 - problem with run script button in console

Normally in left corner of IPython console is button to "run script/stop the current command" but in my program it stuck in "stop" form. I can run scripts with F5 or from the toolbar. While the script is running, the script button in console works, and the script can be stopped with it, but the button doesn't change into "run script" afterwards.
I have absolutely no idea what is responsible. I tried to restart Spyder, restart computer, even reinstall Spyder and reset it to factory defaults. Nothing helped.
This is by design in the IDE. Since you could have multiple files running within the same IDE session, the terminal wouldn't know which one you wanted to run at any given point. That's why the run button/shortcut are specific to one file or selection and are on the top bar. The console can only stop the execution of the currently running statement.
If you want to repeat the statement/file you just ran, type %rerun or %rerun N where N is line number of the command you want to rerun. Other options are here: https://ipython.readthedocs.io/en/stable/interactive/magics.html

How can I run selenium (with python) on an open firefox window? (if not, on a Chrome window)

I have this python program made with selenium that automates a search on a firefox page, with a login and everything.
The thing is, after the search is done, the program stops executing (the page is still open. I want it that way) but I want to somehow implement a function that when -given certain argument- it searchs for something different on that open firefox page.
I don't know if I explained myself, but this is very important to me.
If you know how to do this but with Chrome I don't mind. I only need it to work regardless of the browser.
I'm not that pro at this, so please be patient with me. I'm very grateful for all the help you could provide me.
Thanks!!
https://en.wikibooks.org/wiki/Python_Programming/Interactive_mode:
Python has two basic modes: script and interactive. The normal mode is
the mode where the scripted and finished . py files are run in the
Python interpreter. Interactive mode is a command line shell which
gives immediate feedback for each statement, while running previously
fed statements in active memory.
So basically you need to run your code in interactive mode. It depends on your IDE: If you use PyCharm Right-click on the page that you're writing your code and find Run File in Python Console and continue coding in the new window opened by PyCharm. You can also use Jupyter which is a great tool for interactive mode. For other IDEs, try to find any menu that is related to interactive mode or window.

Pycharm: How to focus on Editor when hit a debug point

I am using a mac, with Pycharm version 2018.2.4 Community version.
When I run a debugging session using the debugger and hit a debug point, I have to click on my editor using my mouse to be able to type code on the editor. If I don't do this and hit my keyboard directly, Mac will complain with some "bing" sound, signaling the keyboard input is not valid to any application (my opinion).
How to make my Pycharm auto focus on the editor when hitting the debug point? Or at least focus on the debugger so that I can hit ESC to focus on the editor?
I have selected "Focus application on breakpoint" in the setting.
This is how it should work:
In Preferences, type Focus application on breakpoint into the search bar and be sure it is toggled on.
Apply that setting and exit Preferences.
In your debugger, when you hit a breakpoint, hit the escape key, and your cursor should be blinking in your editor.
For me, I had to disable the setting, apply, re-enable the setting and re-apply once more.
It now behaves as stated above.
There is a bug reported on PyCharm for the same. Here is the link to the issue. The bug is reported for version 2018.2 and still not fixed.

Spyder retrieve hidden IPython console

Sometimes when I use Spyder and that I press the wrong button or when the computation is too intensive I have my current IPython console that litteraly vanish from my screen. So I open another one with console->open IPython console but the other one seems to be still active somehow.
Is there a way to force the display of the ones that have disappeared ?
Just press ctrl+shift+I for displaying ipython console
or
Its a kind of workaround, Go to view and click on Attached Console Window (debugging) and then open a new console it shows the hidden console.

Categories