Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm not displaying local variables when runing code in console

I have recently reinstalled Pycharm 2018.2.4 professional with a conda install of python 2.7.

Using the same version earlier, I was able to access the local variables after having ran a script in the console. Though, now when I run a script in console only “special variables” are available.

More precisely, if the code runs well, I will be able to retrieve the variable that will be stored at the end. But if the script fails at some point, there is no variable stored. As opposed to before when pycharm was storing values that had been created before the bugged line.

To give you a better understanding, let’s consider the following code :

a=100
b=300
c=b/a

If I do “run in console” the code runs smoothly, then I can do the following

a
>> 100

Now if I change my code to have it do an error :

    a=0
    b=300
    c=b/a

It fails running at the third line. But usually (prior to reinstalling pycharm last week) Any variable created before the error line would still exist. Now, if I run

a
>> error a is not defined

My variables have all been deleted. I don’t understand what’s going on.

Any suggestions is welcome.

like image 930
ylnor Avatar asked Oct 15 '18 16:10

ylnor


1 Answers

Interesting problem, after upgrading to Pycharm 2018.2.4 i can confirm that it is what you describe.

You could use a debug button

enter image description here

Then you can switch to console tab (arrow #1) and you can see the variables (arrow #2)

enter image description here

On console tab you need only to switch on the console prompt button and you are done.

enter image description here

like image 162
Kamil Niski Avatar answered Jan 01 '23 19:01

Kamil Niski