pycharm debugger not working properly - python

I am doing simple python coding in pycharm but the problem is whenever I debug it starts debugging some other file in my project and not the one I am working with.
I did go to run-->edit configuration and check if my file was set for debugging and it was but still it debugs another file when I start debugging.
any help will be appreciated

If you debug using pressing SHIFT-F9 it debugs the last file you debugged, which might be some file you debugged yesterday...
To debug a new file press ALT-SHIF-F9.
You can see these two different debugging options from the Run menu. There is Debug <last file> and there is Debug...

I think you can do it with Right clicking on body of codes and select your project name form there.
Also can select Run > Debug
you can debug it line by line from here

The saving python files with the python module name causing debugging issues.
Replace the files with other name it will work.

Related

VIisual Studio Code using the wrong debugger (PLSQL Debugger) for my Python code

very basic one here. I wrote some Python code that worked fine, then used VS Code for SQL work.
Now I want to reuse Python and try as I might I can't get it to Run without first Debugging in PLSQL Debug. Even if I choose Run -> Run Without Debugging the terminal doesn't load the results of the Python script. Instead I get in the Debug Console:
"Debug started on port 4000, waiting on the client to connect..."
I am sure there is a straightforward answer to this, but how do I get back to VS Code treating my Python code like Python code? Thanks!
Your configurations have been changed when you first run PLSQL debug. Go to your main project path find the .vscode folder and delete launch.json.
After you deleted launch.json file, go to Run and Debug and start a new python debug mode
You can select the debug file type in Run and Debug.

Why do my files in vscode keep being deleted after trying to execute them?

I am currently learning to code with python in vscode but recently I have been having problems with file seemingly deleting themselves after attempted execution (image 1). I have tried Ctrl+z and I have tried recovering them but neither have worked. The files are not in my recycling bin either. If I try to create a new file of the same name in the same folder it shows me a error message (image 2) of "unable to resolve non-existing files"
When I execute my code the file saves but then becomes deleted:
This message appears if I try to undo the delete:
Have you tried to restart vscode? It is recommended that you could try the following aspects:
Check if there is any effect caused by the related expansion. For example, LaTeX Workshop extension has the function of cleaning generated files.
Check your setting.json Files,clear the contents of the user setting.json file and the vs code will return to the default value.
If it still doesn't work, you could consider installing vscode again.
Try running the Python file through a command prompt or terminal using the command python <foo_file_name>. Doing this will either confirm or deny the theory that #jasonharper made in the comments.
If you can run the script that way then we know that #jasonharper was correct and somehow your execute button/command was tampered with.
I had a similar issue using a different programming language. Building generated a file that got deleted automatically.
In my case the Windows 10 default antivirus was the cause. Turned off real-time scanning, tried again and then my files weren't deleted.
Adding an exception for the folder fixed it.
I had the Same problem with a PHP file, and turns out it wasn´t VS CODE. It was my antivirus that was moving the file to quarentine!!

Made OSX .sh file into .app, refuses to execute

To preface, I've read other threads on the topic, but all their solutions don't work for me.
I have a small .sh file that just runs python3 foo.py. I used a script to turn this file into a .app file, but when I try to open it, I can see the app begin to appear in the dock and then disappear. However, when I open the file inside of the Unix executable itself in Terminal, all is well.
I have tried:
Changing the shebang in the .sh file to both #!/usr/bin and #!/urs/bin/env
Creating an empty .plist file
Making sure every file has execute permissions
Oddly enough, running open appname.app gives the following:
LSOpenURLsWithRole() failed with error -10810 for the file /Users/blah/blah/Lofi.app.
Thanks in advance
When you say you've read other threads on the topic, and the solutions don't work, does that mean you tried every thing in the comments under the sh-to-app script? There are a couple of specific fixes enumerated there.
What OS are using? Looks like higher OS needs you to register the app with the OS.
Check permissions of your personal shell script
Does it open in Terminal with open APP.app? I think you're saying it does. You can look at the last comment under the the sh-to-app script for possibly helpful instructions.
Not so much an answer, more of a workaround. I ended up taking the APP.app/Contents/MacOS/APP executable and creating an application in Automator that simply runs the file, and saving that process as an application in the Applications folder.

Pycharm 2017.1 Open Debug Command Line is not working at all

I was not sure if anyone else has run into this issue, but in the new Pycharm 2017.1 the Open Debug Command Line option is not working at all. I created a test case and ran it with py.test with no problem. But when I have a breakpoint and try to Open Debug Command Line the debug console only opens a regular python console with no connection to the underlying debug process. I can't seem to access any variables in the debug scope either.
I have posted an issue to the Jetbrains Pycharm issue tracker issue PY-23401.
In the image below you can see the debug console opened at the bottom of the screenshot. I tried to enter some variable values from the debug session, but don't receive an error and don't receive any info either. Has anyone else run into this, and has anyone found a way to fix this?
It looks like your lower_ml variable is None.
Try going back into the debugger tab, and setting a watcher for it. Or try lower_ml is None in the console.
I have the same problem. Also it's not possible anymore to run individual functions from tests. The 2017.1 release seems to be a bit broken.
The solution for me was to install Pycharm version 2017.1.2. That fixed the issue.

Pycharm Debugger - Frames Not Available

I am having a baffling issue with Pycharm debugger... I am VERY new when it comes to working with the debugger, but I liked the ability to see the variables, etc. of the script to locate and resolve issues. I was making some changes to my directories and the default interpreter... but nothing that would seem to cause the following issue.
I cannot seem to get the variables to show up. I have a traceback showing up, but pycharm debugger just shows "Frame is not available" - so I am not able to troubleshoot to resolve it. See the screenshots below:
I realized that I was not working with breakpoints right. What I wanted was the debugger to stop and load all the frames when there was an exception raised, not when a generic breakpoint was hit (as the breakpoint was in a loop that didnt throw an exception on every iteration). In pycharm, once you run the debugger WITHOUT any breakpoints, you can go back and "View Breakpoints" (Cntrl + Shift + F8 on Windows) change check the "Python Exception Breakpoint". This will cause the debugger to stop and load the frames when an exception is thrown! This was the missing piece in my jumbled mind!
There doesn't seem to be any breakpoints activated - there will be frames available to view only when you hit a particular breakpoint as your program executes: you activate them by clicking column between the line # and actual code, like here:
You can read more about PyCharm debugging here.
I had the same issue with Pycharm.
The project was working fine, but when debugged, it gave me <frame not available> error.
What worked for me is adding these two environment variables.
PYDEVD_USE_CYTHON=NO
PYDEVD_USE_FRAME_EVAL=NO
Reference - Pavel Karateev # JetBrains
I had the same issue with PyCharm, but later found out that i had incorrect Debug configuration.
The "Debug configuration" located at menu Run > Debug... > your_test_file > Edit.
In "Edit Configuration Settings" window,
The line "Script path" in configuration should point out the actual location of the your_test_file.py. After I corrected the path, debugger started to work.

Categories

Resources