ChatGPT解决这个技术问题 Extra ChatGPT

Is there a Variable Explorer for PyCharm

https://i.stack.imgur.com/DH9gy.png

I found this here, that "Variable explorer in Python console (traff)" should be included in PyCharm 3, but I cannot find that. Maybe someone could tell me how to use that tool.


a
andrewmo

The variable list is available in the python console Tools --> Run Python Console... as shown in the screen shot below. Similar functionality for showing variables and watched variables is available in the debugger console.

https://i.stack.imgur.com/kqMXO.jpg


You can paste chunks of code into the console and it will execute. See this answer for how to set up debugging. stackoverflow.com/a/10240047/3435646
Even better than pasting code into the console, just select the code in the editor, right click and choose Execute Line in Console... Then open up the debugger console and see the results. You can also execute chunks of code in the Evaluate Expression... dialog. (One thing I discovered about this is that Print statements show up in the console, not in the expression dialog)
Just switched from Spyder to pycharm as well. I can't find my assigned parameters in this huge list of variables. Is there a way to filter this? Or where can I find if I assign foo = 2 + 2 for example?
I think the Spyder does a better job at being "Matlab" than PyCharm. The variable explorer in Spyder looks more useful, like how one would use it in Matlab.
@ZhouHao there is a new kid on the block, check out JupyterLab, I've been using it. I like how it is light on loading tables.
Q
Quebert

I like Spyder for interacting with my variables and PyCharm for editing my scripts. Alternative Solution: use both simultaneously. As I edit in PyCharm (on Mac OS), the script updates live in spyder. Best of both worlds!


moving towards this! pycharm is more easy to code while spyder is better to understand data
@SrinathGanesh My setup is Anaconda agnostic. Meaning 100% pyenv. But I'm thinking of installing miniconda so I can use Spyder and PyCharm together. Is there any risk of PATHs breaking when installing Anaconda since I already have pyenv/python 3.7 + 3.8 since Anaconda python is also 3.7? Can I just go ahead and install Anaconda?
y
yanes

For your second question: you can also select your code and press shift + alt + E to run a part of your script on to the python console


is there a way to google more information about this functionality? Like what is the name of this functionality? Or you have a link to share?
M
Milad

If you want to inspect variables that contain arrays or datasets, like Spyder and see them as a nice table, you can do bellow :

https://i.stack.imgur.com/PcFDA.png

2- Run the debugger ( the little bug on the top-right side of pyCharm).

https://i.stack.imgur.com/0HYYJ.png

3- Right click on the variable and select View As DataFrame

https://i.stack.imgur.com/WQjnG.png

4- You then will be presented by a nice table like below :

https://i.stack.imgur.com/xESFD.png


what I have is that in debugger mode there is both a console window and a debugger window but the debugger window does NOT show me what my print statements are printing. Which I find annoying. The ideal thing would be is both the debugger and the console in debug mode had the Variables watching panes. Is that not possible?
C
Cyr1lfiggus

PyCharm has SciView for exploring variables in almost exactly the same manner as Spyder. Simply execute the selection or cell in console, then click View as Array in the Special Variable pane. Special Variable Pane


Thank you for pointing out, SciView feature of Pycharm will give you the same data visualization as Spyder, simply select the part of code you want to execute and press shift + alt + E to execute and then visualize in SciView by clicking on View as DataFrame.
M
Maulik Madhavi

The simple trick:

put any dummy line at the end of your code, e.g.

print('hi')

and set break point at this line.

Then, run your code in debug mode. Enjoy! The screenshots of editor and debug window are shown for your reference.

https://i.stack.imgur.com/FcY1j.png

https://i.stack.imgur.com/WIRXD.png


what if I want to see what is being printed to the console AND the variables at the same time?
@CharlieParker you can click to the "4:Run" and see the console stdout
C
Charlie Parker

The question is vague so this might be helpful to someone.

For me I managed to have the Console (so that printing in my script would be shown) AND the variable pane at the same time while in debug mode. For that I did this:

Run code in debug mode Drag and drop the console into the debugger pane so that now both are together at the bottom pane.

Visual explanation fo what I did:

In (I assume default) debug mode:

https://i.stack.imgur.com/Pid5w.png

during drag and drop:

https://i.stack.imgur.com/EnC0s.png

and after finally I dropped it and it looks the way I want it:

https://i.stack.imgur.com/ouSfv.png


d
dragon7

If you want to inspect numpy arrays, which are images, you can use OpenCV Image Viewer Plugin.

https://plugins.jetbrains.com/plugin/14371-opencv-image-viewer

https://i.stack.imgur.com/IwzXD.gif

Disclaimer: I'm an author of this plugin


d
dduque

Right-click on the file and click Run file in console. Everytime you run it, the variables will show in the console until you click the stop button.


B
Brian Tompsett - 汤莱恩

If you want to view the complete dataset or an array do this:

Go to python console in pycharm On the right usually, in the special variables tab, scroll down and find your data frame or csv you want to visualize. Right click on the data frame/dataset and see for the option view as array/data frame. There you go, you can see a tab opened containing your data.


H
Harnoor Singh

Step 1. Make a breakpoint by pressing on the right of the line numbers. Step 2. Click the debug button or right click then debug Step 3. Press the button above the settings button in the console to view the variables Step 4. Double click the variable of what you want to check the values. You can also right click that particular variable and view it as a dataframe.


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now