Pycharm-Execution does not stop at breakpoints during debugging - python

I am trying to debug python code in Pycharm. I assign a break-point on a line using ctr+F8 and then debug using the debug icon on top right corner.
However the execution does not stop at the breakpoint and whole code is executed.
I am trying to stop the execution at breakpoint and then execute the code line by line while checking the variable values.
What possibly I am doing wrong? It does not work on other code files which I created for checking.

See the answers in this issue Unable to debug in pycharm with pytest. For me it was deleting the __pycache__ directories because I had copies the project over from a different computer.

In order to debug (and stop at a breakpoint) you need to use Run > Debug (Alt+Shift+F9), not Run > Run (Alt+Shift+F10).

Related

How can I debug a shell script file containing an executable command in pycharm?

I have a shell script file that contains the necessary parameters to run
the Python file. I can only run this script with the green button on the top right of pycharm, but when I select the debug option, it
quickly goes out of debug mode. This script file contains the python 3 command.
How can I debug code with this script?
You're asking PyCharm to debug two different programming languages at the same time. Instead, create a Debug configuration for your Python script with all the necessary parameters: https://www.jetbrains.com/help/pycharm/creating-and-editing-run-debug-configurations.html
This might take a moment to set up but you will then be able to set breakpoints and debug your Python script.

Unable to run python code on Visual Studio, crashes after Launching Debug Editor

I was trying to get datetime.py working as one of the functions from it just didn't exist in my datetime.py file. In my datetime.py the fromiso() function is not present in the code. To test it I opened a new VS project and tried compiling a small code snippet that would only invoke the missing function from datetime after import, and that's when I first encountered this problem. I'm not sure if this is related to this problem, but this is the last thing I was doing.
When running the code it will flash console quickly before opening "Launching debug adapter" window, this will prevent me from doing anything for maybe 10s and then will return to the starting point having neither executed my code nor opened the debugger.
Now I am unable to run any program whatsoever, running with either ctr+f5 or fn+f5 leads to same glitch. I have not touched anything in the VS settings prior. I have tried powercycling just for a good measure, but sadly that didn't fix anything. Running as admin yields same result.

How to see which part of the code is running in terminal

When you run a python script from terminal and before it completes running of you control + c it, it gives a traceback where the code was currently running. Is it possible to see which part of a code is running without terminating it.
in pycharm, you can debug by selecting code areas that you want to work, and by pressing next and next, you'll see how does program running it, without terminating it.
You can do this in PyCharm using the debugging facility. It allows you to step through your code line by line, running each line as you pass it. You can see what variables have been assigned etc. Very helpful for debugging!
See here: https://www.jetbrains.com/help/pycharm/part-1-debugging-python-code.html

Pydev Django project compilation

I installed pydev and eclipse to compile a django project. Everything looks good but one thing makes me crazy. When i change something in the code, i click to save it and hope to see the effect of changes. However, I cannot see the effect of what i change unless I terminate the program and re-run as as shown below. It is such a pain...
I used to use Pycharm, but it expired. In Pycharm, when the program runs once, i do not need to run it again and again. I can easily see the effect of my changes on the code by clicking save button. Is it possible to see the same thing in pydev and eclipse? Do you guys also see this issue?
To debug Django with the autoreload feature, the Remote Debugger must be used and a patch must be applied to your code (just before the if _name_ == "_main_": in your manage.py module):
import pydevd
pydevd.patch_django_autoreload(
patch_remote_debugger=True, #Connect to the remote debugger.
patch_show_console=True
)
So, doing that, starting the remote debugger and making a regular run should enable all the regular breakpoints that are put inside Eclipse to work in the Django process with the Remote Debugger (and the --noreload that PyDev added automatically to the launch configuration must be removed).
I have plans on improving that so that the debugger will automatically add tracing to spawned processes (probably for the next release), but on PyDev 3.3.3 this still requires doing this manual patch and using the remote debugger.
The above is related to a debug run. Now, on to the regular run...
When you do a run as > pydev: django, it should create a run configuration (which you can access at run > run configuration). Then, open that run configuration > arguments and remove the '--noreload' (leaving only the 'runserver' argument).
Then, you can simply rerun it with Ctrl+F11 (if you've set it to launch the previously launched application as indicated in http://pydev.org/manual_101_run.html)
-- (Or alternatively you can run it with: Alt + R, T, 1).
The only problem is that if you kill the process inside Eclipse it's possible that it leaves zombie processes around, so, you can use the pydevd.patch_django_autoreload(patch_show_console=True) as indicated above to open a console each time it spawns a new process (you can do a pydevd|<- ctrl space here to add an import to pydevd).
Note that this should work. If it's not working, make sure you don't have zombie processes around from a previous session (in windows you can do: taskkill /F /IM python.exe to make sure all Python processes are killed).
Another note (for when you don't actually have automatic reload): Ctrl+Shift+F9 will kill the currently running process and re-run it.

PyCharm debug jump to

http://i.stack.imgur.com/8LzEj.png
Hi,
I am using PyCharm 2.7.3, the newest version to this date
I am writing a simple script called hour4.py
I want to debug that script. So I hit Alt+Shift+F9 to open the debug script dialoague and then I choose from the list hour4.py. This is where it all goes wrong.
Instead of PyCharm debuggin my script hour4.py it jumps over to pydevd.py and starts debugging that one instead. In the bottom of my screen it shows its debugging hour4.py but its clearly not.
Thanks for anything that helps
Open Run | View Breakpoints and disable the Python Exception Breakpoints:
You also need to ensure that your script has no syntax errors, otherwise it will fail to load and you will step into pydevd.py instead.

Categories