How to debug a scratch file in Pycharm - debugging

I am running python3.5 from a venv and am using PyCharm 5. My debugger works fine on normal scripts but doesn't allow me to step through my code at all on a scratch file. Is this normal? It won't even let me set breakpoints. Its driving me bonkers that I can't debug them!

This looks like a bug in pycharm 5.0 - PY-17575 Can no longer set breakpoints in scratch files

Related

Pycharm does not activate venv when debugging - no problem when simply run

As in a title. I run the project in venv. It runs correctly with Run Configurations without debug mode but in the debug mode seems not to have the venv activated (spits out errors about modules not found). What could be the reason? I can add more details if you need but I am not sure what could be useful.
EDIT: After closer inspection it looks like the debugger mode does not use the Debug Configurations at all. I've got Python app specified with app.py as a path, debugger tries to run Flask app and core.py.

CLion (C++) : unable to open image using SFML

I just started using CLion to build my projects and tried to launch one of my previous ones to test. Compiler doesn't return any errors, but when I try to run the executable it says unable to open "img.png" but it worked fine when i compiled it in terminal and launched.
I figured it out in case anyone faces the same problem. CLion searches for resources in debug/release folder by default. Changing the default directory or writing "../img.png" instead of "img.png" solves the issue.

How to debug code running from terminal in pycharm

I am running my code in Pycharm from Terminal. Is it possible to debug the code and put breakpoints inside the code during a run from terminal?
I don't know anyway to do this through the terminal, but the way I currently do it is:
Run > Edit Configurations > Add new configuration (the green + button)
Choose Python
Fill out Script path, Parameters, and other configuration fields.
Debug the newly added configuration. (Run > Debug...)
With the right configuration the result should be the same as running the script in a terminal.
I find the above process a little tedious. A PEP 553 breakpoint() might be nicer. It requires Python 3.7 and is not implemented yet. See the related issue.
Even if the program is started outside of PyCharm, we can attach PyCharm debugger to it.
Go to Run -> Attach to process.
This will show a list of python process that are currently running on the system. Select the appropriate process from it.
Now PyCharm debugger is connected to that process. We can add breakpoints and debug it.
There is a way using python console.
To run it: Tools -> python console .. or you can find it at the bottom of the IDE.
Then press on 'Attach debugger' line in the following picture:
Add a breakpoint in your code and then pass the file name to the cosole, like: %run my_file.py

Why does PyCharm say "Unable to display frame variables" in debug mode?

I have several python projects loaded in one pycharm workspace. All but one I can step into normally. One project, however, when I set a breakpoint on, say, the first line of the boilerplate, pycharm says it's Collecting data... for about 10 to 20 seconds then says Unable to display frame variables.
Trying to step over or into the code freezes pycharm for another 20 seconds.
PyCharm still stops at breakpoints, I can see the stack and, with some patience, click on the frames.
I've checked the project configuration and everything seems the same as the other projects, or consistent from one project to another, including the Project, Environment variables, Python interpreter, Interpreter options (none), Script and Working directory.
I've tried running the project in a separate workspace with the same results.
I've reinstalled the debugger as suggested here
I've upgraded to 2016.3
I was using PyCharm 2016.2.3 with Python 2.7.12 :: Anaconda 4.1.1 (x86_64), now PyCharm 2016.3
What am I missing?
You should put the Pycharm Debugger in gevent compatible mode.
File > Settings > Build, Execution, Deployment > Python Debugger > Gevent compatible
The lines you removed probably had a purpose and you shouldn't delete them without knowing the consequences.
The code, which I didn't write myself, contained the following:
from gevent import monkey
monkey.patch_all()
Removing those lines resolved the issue.

Develop and debug Python 3 applications in a virtual environment with Komodo IDE 8

I was trying to develop and debug Python 3 applications in a virtual environment with Komodo IDE.
I applied all the project settings, tried out my tests and did a lot of research using google, stackoverflow and also tried sarchiung the komodo forums for "virtual environment" oder "venv".
My impression is, that this cannot be done at the present. Or is there a way?
How can debugging in a Python3 Virtual Environment be done in the current commercial Komodo IDE version on windows?
Debugging in a Python3 Virtual Environment does not work yet in the current Komode IDE version on windows.
My experience is, that even if the path is properly set on debug sessions in the project settings, those are ignored in the debug session and even worse, Komodo uses c:\Python27 which should not be visible in the session.
Example:
I have c:\python27 and c:\python33 on the system
My Python 3 VENV is in c:\project\demo and I added the python 3 exe from c:\project\demo\scripts\python.exe to the project settings
I also set the environment variabels PYTHONPATH and PATH to
c:\project\demo\scripts\ respectively c:\project\demo\ and c:\project\demo\mylib
Also c:\project\demo\mylib is added to the python3 search paths.
I can run my tests from a VENV from the console withpout any problem, which has exactly the mentioned configuration.
Now I open the file with the test in the Komodo project and run / debug it.
The result is that the debug session cannot import from c:\project\demo\mylib. When I print the environment in the debug session, it shows me that it is set to c:\Python27
I wonder why all those settings exist if the debug session does not use them.

Resources