Pycharm Debugger - Frames Not Available - python

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.

Related

'Invalid Python SDK' error right after creating a new project in PyCharm

Background
Some time ago I seriously crashed my Windows computer while using PyCharm - I remember some errors about memory and then a hard crash with no blue screen - just black with some thin vertical lines and reboot to Windows installation / fixing screen. Since then, I had this problem, with no way I found online to fix this.
Edit : Apparently, this has nothing to do with the problem.
The problem
Whenever I open a project, or create a new one, an error appears with the Invalid Python SDK error message.
**Invalid Python SDK**
Cannot set up a Python SDKat Python 3.9 (%projectName%) (%projectPath%).The SDK seems to be invalid.
Also, this is what the work environment looks like the moment I close this message. In the Project window, the venv directory (and every directory under it) is marked as an Exclusion, and in the code, the print(f'Hi, {name}') function is marked as an unresolved reference error shown below. The program, however, executes flawlessly.
What's more, when I go to Python Interpreter settings at File -> Settings -> Project -> Python Interpreter there's a yellow bar on the bottom which says:
Non-zero exit code (4).
which after some time says:
Python packaging tools not found.
Upon installing, nothing changes, and I can't add packages from this screen (the '+' button is greyed out):
When I try to check Python interpreter paths, there are no paths shown, and I don't know what that means:
In short, all of the default Python functions like print are marked as errors, even though they work when executed. This makes coding extremely confusing, as I can't quickly distinguish between real errors and 'errors'.
The search for solution
Normally this would be a problem with interpreter set-up or path, but I've tried most of the methods proposed in other answers to similar questions. To name a few :
PyCharm shows unresolved references error for valid code
'Cannot setup a Python SDK' in PyCharm project using virtualenv after OS reinstallation
Why do I get an 'SDK seems invalid' error when setting up my Project Interpreter in PyCharm?
Invalid Python SDK Error while using python 3.4 on PyCharm
Invalid Python SDK when setting a venv
There were supposed to be links, but I don't have enough reputation on Stack Overflow to post them with the questions. These, however, can be easily looked up in Google, all of them are posted to Stack Overflow.
What I tried
I should mention that the first things I tried were removing and installing PyCharm, all user configurations and Python itself as well. I installed Python from the official site, and from the PyCharm application, both methods ended with the same result.
File -> Invalidate Caches... -> Invalidate and restart. Didn't work.
Checking file interpreter in Edit Configurations. Don't know what to make of it. The result:
Refreshing the interpreter paths. Even now, the paths yield no results.
Removing the interpreter and adding it again. No result.
Deleting the .idea folder. No result.
Deleting PyCharm user preferences under %homepath%/.PyCharm50. I don't have that folder though.
Switching interpreter back and forth. No result.
Creating a new interpreter in a different location. No result.
Marking project directory as root ProjectName -> Mark Directory as -> Sources Root and unmarking other directories as Excluded. No result.
Using no interpreter. Yeah, it doesn't mark non-errors as errors anymore. But the code doesn't work. That's not a solution for me.
Checking if venv/pyvenv.cfg has paths set correctly. These look fine to me.
Checking Windows environment variables - Path variable. It was in the user section, but wasn't in the system section. I added it, restarted but still no result.
Changing account name in Windows. My account name was 'username' and that's how my User folder is called `C:\Users\username', but I later connected it to Microsoft account and my user name is now User Name with a space and I can't really change it. My folder stayed the same. Not sure if I can fix it that way.
To the two last things I tried I should also add that I changed my Windows username from 'username' to 'user name' with a space, but that wasn't until recently.
I'm attaching the idea.log file for you to check. I replaced my real username with 'User Name' to highlight the existence of a space.
OK, that was a lucky one! I'm thus posting my comment as an answer:
The problem is caused by the non-ASCII characters in the path, and the solution is to remove them. As indicated by #TheLazyScripter this is a known issue.

Getting a "The process failed to start (invalid command?). (1)" error when starting up Pyzo

I recently booted up my Pyzo IDE with the intention of doing some programming, however, upon starting up the python shell it gave this following error:
The given path was not found
The process failed to start (invalid command?). (1)
I am not able to run any code with this error. If I try to run it nothing happens and the error re-appears.
I have tried reinstalling the whole thing without success, I have tried reading the log but there was no error message and I have also tried looking for posts regarding the same problem without success. I was hoping if someone could explain what my problem is and a possible solution, thanks.
This is how I fixed it:
I went to miniconda3 file in C:\Users\<user>\Miniconda3 (might be in other file/the thing is you need to find the miniconda3 file)
Find the Python application
Rename it to "python.exe"
Then go to shell configuration and replace the path to the operable python program in "exe" with your path (for me it was
C:\Users\<user>\Miniconda3\python.exe)
For me the solution was much simpler than the solution proposed.
I had misspelled the path to python.exe
Go to Shell tab
Press the button that says Python and has a small arrow at the right bottom
After pressing the button a drop-menu will appear. In this meanu choose Edit shell configurations ...
A new window will open. In this window put the correct path in the exe field
The path for me (windows 7) was c:\users\user\appdata\local\programs\python\python38\python.exe. For other users might be different

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.

Setting Breakpoints in IDLE [duplicate]

I solved this already, I'm just posting it here because I couldn't figure it out with google, or by reading the docs. I only found it by accident.
To add a breakpoint, right-click on the line that you want to add a breakpoint on and select "Set Breakpoint". The line will become highlighted. (Note that this only works when you are editing a file; it does not work at the interpreter.)
This site has a detailed tutorial about using the IDLE debugger.
On Mac, you need to Control-click instead of right clicking.
Completing the answer supplied by the OP: after setting the breakpoint - you must turn on IDLE Shell's debug mode (using debug --> debugger). When you run the program, press "Go" in the debug window that opens up and IDLE will stop at the breakpoint.
IDLE Shell is the window that appears when you hit F5 to run your Python script.
There is an open Python issue about the lack of documentation for IDLE breakpoints. Contributions welcome!
Update: The on-line documentation and the IDLE help files (for 2.7.4, 3.2.4, and 3.3.0) have been updated, with Nick's help.
You can set breakpoint before it is run.
Set the breakpoint by right clicking on the relevant line of your program
On your python shell, look for Debug - [Debug On] will be shown in your IDLE Python shell
Go back to your program and press F5(hotkey) to run the program, it will stop in the relevant break line(s)
If you want to look at some global variables or line of codes, you can check the box in the debugger
Just adding to this answer (would've commented but for the rules that say I don't have enough reputation to do so): On the Mac you must control-click. The normal "right-click" at least for the trackpad does not work to bring up the contextual menu with the option to set a breakpoint.

How do you add breakpoints to a Python program in IDLE?

I solved this already, I'm just posting it here because I couldn't figure it out with google, or by reading the docs. I only found it by accident.
To add a breakpoint, right-click on the line that you want to add a breakpoint on and select "Set Breakpoint". The line will become highlighted. (Note that this only works when you are editing a file; it does not work at the interpreter.)
This site has a detailed tutorial about using the IDLE debugger.
On Mac, you need to Control-click instead of right clicking.
Completing the answer supplied by the OP: after setting the breakpoint - you must turn on IDLE Shell's debug mode (using debug --> debugger). When you run the program, press "Go" in the debug window that opens up and IDLE will stop at the breakpoint.
IDLE Shell is the window that appears when you hit F5 to run your Python script.
There is an open Python issue about the lack of documentation for IDLE breakpoints. Contributions welcome!
Update: The on-line documentation and the IDLE help files (for 2.7.4, 3.2.4, and 3.3.0) have been updated, with Nick's help.
You can set breakpoint before it is run.
Set the breakpoint by right clicking on the relevant line of your program
On your python shell, look for Debug - [Debug On] will be shown in your IDLE Python shell
Go back to your program and press F5(hotkey) to run the program, it will stop in the relevant break line(s)
If you want to look at some global variables or line of codes, you can check the box in the debugger
Just adding to this answer (would've commented but for the rules that say I don't have enough reputation to do so): On the Mac you must control-click. The normal "right-click" at least for the trackpad does not work to bring up the contextual menu with the option to set a breakpoint.

Categories

Resources