I've had a strange occurance. I stopped a python script manually, but its still running. It shows it as stopped in my IDE (Spyder) but I can see it's still running in task manager. I also know it still processing because its still outputting files to a directory.
Does anyone know why this is happening and how I can prevent it on a go forward?
Got it, i needed to add Exception to my except statement. Thanks gerosalesc and Dot_Py for your help.
Try/Except in Python: How do you properly ignore Exceptions?
Related
My current (PyCharm based) debugging workflow is to run a program in debug mode. When I run into an error, I fix it, and restart the program from the beginning.
Is it possible to save re-running the healthy part of the program by moving the program back by one step, fix the issue, and continue the program?
Is there a general way to do this, and one specific for PyCharm?
[edit:]
this is related but not similar to Is there "Edit and Continue" in PyCharm? Reload code into running program like in Eclipse / PyDev? , as there the author anticipates halts the program before an error occurs. here, i consider an error state
I'm using PyCharm for debugging. One of the big headaches that I keep having is that even in debug mode, the IDE exits on an exception instead of breaking. There are already questions about this issue but they're all years or even a decade old, and PyCharm's UI has been heavily redesigned in the past years. Here's the Breakpoints window.
Link to the image (not enough reputation :():
https://imgur.com/8aZgFdT)
If I check the 'On raise' box, it breaks on handled exceptions which is unnecessary and unwieldy.
Here's the debug console. I want it to break on the failed assert instead of just exiting. https://imgur.com/X2BxW4S
Your settings seem OK. When I tried to reproduce the case the PyCharm IDE just stopped right at the AssertationError. Note the debug window in the bottom of the GUI where you can inspect the stack trace and variables. The last line Process finished with exit code 1 of your screenshot was not printed at that point.
Possible cases for exiting:
running the code (Shift+F10) instead of debugging (Shift+F9)
using a library that actually handles the exception (e.g. Jupyter notebook or unittest module)
and a less probale scenario that should have other symptoms: the python version 3.7 may be too new to the specific PyCharm, at least there was an incompatibility when using numpy https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001194720-Numpy-import-error-in-PyCharm-Importing-the-multiarray-numpy-extension-module-failed-
This question is a possible duplicate for Break on unhandled exception in pycharm
I am using Spyder (3.2.6) on a Mac, running python code that starts by loading/processing some large data files.
When stepping through my code if I encounter an error, is it possible to fix the error and continue stepping - rather than run everything from the beginning again (and wait for all the data to load/process)?
Encountering an error seems to 'end' the run/debug mode at the point of the error, and I can't seem to find a way to continue.
Thank you for you help.
Good Day All,
I finished writing the site blocker process and then i renamed the "py" file by appending "w", double clicked to run it yet the process did not show up in the task manager. I tried it a few times and yet nothing showed up. Mind you I am on Win 10 OS.
You have any suggestions to help fix this such that is shows up in the task manager as pythonw.exe process ?
If the process isn't showing up in the Task Manager, it's very likely that it's immediately quitting with an error. Even trivial changes to the code cause this to occur. Without the console showing output it's hard to tell what that error is. Try renaming the file back to filename.py and running it to see if an error is occurring.
Another possibility is that the script is completing so fast you don't have time to see it. Did it run instantaneously when it was named filename.py?
I am pretty new to Python and I have been pretty annoyed with this problem. I am not sure if this matters, but I run my .py file with Python 2.7.6 with python installed on my computer, not using it on any online thing or other program. Every time I come across an error, my program works fine until it comes to the error, but the window disappears right before I can possibly read whatever the error said it was... Anyways, I haven't been able to find out what is wrong with my programming, and I am tired of guessing and guessing what is wrong. How can I extend the time so I can read the error message? Or something like that? Thanks
You should run it from command window/terminal instead of double clicking on the file.
Yes, as #shortfellow said, running it from the terminal should work:
python your_file.py
Another tip that helps in Python, if you are having a hard time with errors, is to use iPython for debugging/testing code on the spot. You can give it a try.
http://ipython.org/