Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables don't show up in variable explorer (Python 3.6) #4154

Closed
sayboltm opened this issue Feb 16, 2017 · 46 comments
Closed

Variables don't show up in variable explorer (Python 3.6) #4154

sayboltm opened this issue Feb 16, 2017 · 46 comments

Comments

@sayboltm
Copy link

sayboltm commented Feb 16, 2017

Description

What steps will reproduce the problem?

  1. Open Spyder
  2. Write some code with variables (even a constant)
  3. Run the code and variables don't show up, not even the constant 'epsilon'

What is the expected output? What do you see instead?
I expect to see some output in the variables explorer. This happens on both Spyder 3.1.2 Linux and Windows.

Please provide any additional information below
Here is my code, attempting to implement Gaussian elmimination:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 16 17:40:09 2017

@author: 
"""

import numpy as np


def f(x):
    return 100*np.exp(-10*x)

def exact(x):
    return 1.0-(1-np.exp(-10))*x-np.exp(-10*x)

# Hardcoded params for simplicity
#fileout = pyOutput
exponent = 4
#n = 4

for k in range(1, exponent):
    # Weird thing we didn't understand
    n = 10**k
    
    # Append i to filename
    fileout = 'pyOutputSimple'
    fileout += str(k)
    
    # descretization resolution
    h = 1/n
    hh = h*h
  
    ''''''
  
    d = np.zeros(n+1)
    b = np.zeros(n+1)
    x = np.zeros(n+1)
    solution = np.zeros(n+1)
    
    d[0] = 2
    d[n] = 2
    solution[0] = 0
    solution[n] = 0
    for i in range(1,n):
        d[i] = (i+1)/i
    for i in range(0,n+1):
        x[i] = i*h
        b[i] = hh*f(i*h)
    
    # FW sub
    for i in range(2,n):
        b[i] = b[i] + b[i-1]/d[i-1]
    # Backward sub
    solution[n-1] = b[n-1]/d[n-1]    
    for i in range((n-2),0):
        solution[i] = (b[i]+solution[i+1])/d[i]
        
    with open(fileout, 'w') as fout:
        fout.write('x:\t\tApprox:\t\tExact:\t\tRelative Error:\n')
        for j in range(0,n):
            RelativeError = np.abs((exact(x[j])-solution[j])/exact(x[j]))
            fout.writelines('{0:.8f}'.format(x[j]) + '\t')
            fout.writelines('{0:.8f}'.format(solution[j]) + '\t')
            fout.writelines('{0:.8f}'.format(exact(x[j])) + '\t')
            fout.writelines('{0:.8f}'.format(np.log10(RelativeError)) + '\n')
    fout.closed
    print('File: ' + str(k) + '/' + str(exponent) + ' written.')

Version and main components

  • Spyder Version: 3.1.2
  • Python Version: 3.6.0
  • Qt Versions: 5.6.2, PyQt5 5.6 on Linux

Dependencies

numpy is used

pyflakes >=0.6.0 :  1.5.0 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
pandas >=0.13.1  :  0.19.2 (OK)
numpy >=1.7      :  1.11.3 (OK)
sphinx >=0.6.6   :  1.5.1 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
jedi >=0.8.1     :  0.9.0 (OK)
psutil >=0.3     :  5.0.1 (OK)
matplotlib >=1.0 :  2.0.0 (OK)
sympy >=0.7.3    :  1.0 (OK)
pylint >=0.25    :  1.6.4 (OK)

@ccordoba12
Copy link
Member

Does it happen only in Python 3.6?

@sayboltm
Copy link
Author

As far as I can tell, yes. I did not have these issues with Python 3.5 and Spyder 2.3.8 on my other Windows 7 machine.

@ccordoba12 ccordoba12 changed the title Variables don't show up in variable explorer Variables don't show up in variable explorer (Python 3.6) Mar 5, 2017
@ccordoba12 ccordoba12 modified the milestones: v3.2, v3.1.4 Mar 5, 2017
@ccordoba12
Copy link
Member

Please update to Spyder 3.1.3 and try again. Our tests are running just fine in Python 3.6, and they detect if objects are displayed in the Variable Explorer.

@cefn
Copy link

cefn commented Mar 8, 2017

I believe I am also experiencing this issue and I am running 3.1.3 on Ubuntu. Ipdb reports...

ipdb> sys.version_info
sys.version_info(major=3, minor=5, micro=2, releaselevel='final', serial=0)

I was able to see the function of the Variable Explorer against this simple file...

substitutions = dict(planet="World")
print("Hello {planet}".format(**substitutions))

...and it correctly visualised the substitutions dict

However, when interactively running against this file...
https://github.com/cefn/avatap/blob/6ad61cb3b8e198acae1caa6f187726fea4834b30/python/test.py
...nothing is shown in the Variable Explorer window, even from the very first line of the first local import.

However, the interactive ipdb pane is indeed able to inspect variables when running that file, for example, at a Spyder breakpoint on line 28 in test.py, I can do...

ipdb> !locals().keys()
dict_keys(['BoxPassage', '___', 'Engine', 'ticks_ms', 'loadStory', '_oh', '_iii', 'ChoicePassage', '_ih', 'storyUid', '__package__', 'ConfirmationPassage', '_sh', '_', 'uidInitTypes', '__name__', 'UidRegistry', '__file__', '_i1', 'boxUids', 'getStoryContext', 'Card', 'UidItem', '_ii', 'In', '__builtins__', '_i2', '_dh', 'Container', 'Uid', '_i', '__', 'ConditionalPassage', '__spec__', 'passageUids', 'Box', '__doc__', '__builtin__', 'Story', 'Out', 'AnonymousContainer', 'PagePassage', 'exit', 'story', 'Item', '__loader__', '_i3', 'MockEngine', 'Passage', 'unittest', 'quit', 'get_ipython'])

...while nothing at all is shown in the Variable Explorer.

I made sure to remove all spyder and spyder3 ubuntu packages via apt-get purge , then installed via pip like...

sudo -H pip3 install --update spyder

To be doubly sure there was nothing weird going on, I then ran...

pip3 freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 sudo -H pip3 install --upgrade

...to upgrade all pip3 packages to the latest, but still Spyder's Variable Explorer is not cooperating.

@ccordoba12
Copy link
Member

ccordoba12 commented Mar 8, 2017

Ok, if this issue is about debugging, then that's a bug and it was reported in issue #3711.

It will be fixed in Spyder 3.2.

@cefn
Copy link

cefn commented Mar 8, 2017

Oops, I think looking in more detail perhaps the OP wasn't running the code through the debugger as I'd assumed, so I may have mistakenly hijacked this bug. I hadn't realised there was a variables viewer indicating the state of 'module' symbols at the end of a run, so I just assumed that the behaviour described was linked to debugging. My bad. Perhaps the OP can clarify.

@cefn
Copy link

cefn commented Mar 8, 2017

@ccordoba12 is there a pull request where I can contribute testing for this feature against the expected fix to land in spyder 3.2? I tried merging your debugger-improvements branch into spyder:head as per cefn#1 but this doesn't change the behaviour of the Variable Explorer under the debug scenario described (although the IDE seems stable and otherwise functional).

Perhaps it's a 3.2 wishlist item to solve it and the code to solve it hasn't been written yet? Let me know if there's anything where live testing is useful.

@ccordoba12
Copy link
Member

There is an option in the Variable Explorer called Exclude unsupported types that if uncheck will show all variable types on it.

@sayboltm
Copy link
Author

Yes @cefn this issue was occuring when not in the debugger. The variables should be updated at the end but they aren't if they even show up at all. The debugger seems to work most of the time. I can get them to show up if I run the debugger, but then after they do not update with subsequent runs. These are supported types like native Python types (string, int, list, etc). Thanks for looking into this

@sayboltm
Copy link
Author

sayboltm commented Apr 28, 2017

Just wanted to chime back in and say that the variables are now showing up fine in Spyder 3.1.3 on Linux when using the following configuration in a conda virtual environment yml file:

https://github.com/sayboltm/tmp/blob/master/spyder_working.yml

I have a hunch that the version of QT I was running before may be related to the issue. I have had a lot of issues with QT for python with other projects that I only recently got sorted out.

Edit: github link instead of pasting whole yml file

@sayboltm
Copy link
Author

Nevermind. Of course after many tests, as soon as I post that, it won't show the variables after a run in variable explorer. Well, there is my configuration. I hope you guys can fix that because that is hands-down my favorite feature and reason I use Spyder.

@bborghetti
Copy link

image

I had the same problem as soon as I upgraded from spyder 3.1.3 to spyder 3.1.4. Notice that under Tools / Preferences / Variable Explorer / Autorefresh there is a checkbox which might need to be checked (mine was off after the upgrade)

@sayboltm
Copy link
Author

sayboltm commented May 2, 2017

I examined that box and it was unchecked, but much to my dismay, checking it, restarting spyder still did not fix this seemingly intermittent issue. This is quite puzzling.

@paoloangeles
Copy link

Has this been fixed? I run my code successfully but I am unable to view any of the variables in the variable explorer afterwards. Why is this? Spyder 3.2.0 with Python 3.5.3.

@vishalnadagiri
Copy link

facing same problem here, I'm ruining Spyder Version: 3.1.4
Not able to view the datatypes !!
and am new here!!
help me to solve it. :)
capture

@Prikers
Copy link
Contributor

Prikers commented Sep 29, 2017

Thanks @vishalnadagiri. Currently object-arrays (with dtype=object, meaning with non numeric data) are not supported. There is already an on-going PR (#5260) to add this functionality. It will be available in a future release.

Meanwhile:

  • you can view your data X if you keep it as a DataFrame (just remove .values in your line 10)
  • or you can view it as an array if you remove the non-numeric data (the first column in your case)

@vishalnadagiri
Copy link

vishalnadagiri commented Sep 29, 2017

Thank you @Prikers for the help, I just got to view the DataFrame by removing .values and it worked fine and can view the DataFrame!!

@sayboltm
Copy link
Author

I have still seen this issue occur and as a result I run Spyder 2.3.8 when I really need to count on it to update and work properly. Problem is, that requires old matplotlib which limits what else I can work with.

Just for this thread's sake I have begun testing Spyder 3.2.3 (latest supported by conda as of now) and go figure the variable explorer appears to be working. but I swear I tried on Linux and Windows with newer versions and it only sometimes works.

The worst part is when it works at first, populates with variables (so you think its working), then quits working so the old data stays there and you wonder why your variables aren't being assigned properly etc. but its actually the variable explorer dying. When this happens I verify by typing a known supported type (int, string) into iPython console and see that it is not added into the variable explorer. Glad to see some activity here, I'll check back as I love the variable explorer. Favorite feature of spyder for sure!

@sayboltm
Copy link
Author

@Prikers Looking forward to this! Love being able to get people away from Matlab and into Python and open-source using Spyder as a gateway!

@Prikers
Copy link
Contributor

Prikers commented Sep 29, 2017

@sayboltm if you can have a reproducible simple example, I will be willing to investigate!

@JasperAustin
Copy link

I got similar problem with Spyder 3.1.2 and Python 3.6. I do see my variables listed in Variable Explorer. But if I double click the array or matrix variable, I can't see the whole array or whole matrix as I used to be able to with 2.* version of Sypder. Can someone shed me some lights on how to get around this please? Thanks much in advance!

@JasperAustin
Copy link

The error message I received: 'Spyder was unable to retrieve the value of this variable from the console', with additional error message of 'Inspecting and setting values while debugging in IPython consoles is not supported yet by Spyder'. Nevertheless I am pretty sure that I could see the content of the whole dataframe in 2.* version of Spyder.

@Prikers
Copy link
Contributor

Prikers commented Oct 3, 2017

@JasperAustin are you trying to see the variables while running the debugger?
Is your problem similar to this issue?

@JasperAustin
Copy link

Yes, @Prikers , I'm trying to see the arrays in debugger

@ccordoba12
Copy link
Member

ccordoba12 commented Oct 3, 2017 via email

@JasperAustin
Copy link

Thanks, @ccordoba12. I'm new to Python. How can I update to Spyder 3.2 from 3.1.2?

@ccordoba12
Copy link
Member

If you are using Anaconda you need to run in a system terminal (cmd.exe, Terminal.app or xterm)

conda update spyder

If not, please run

pip install -U spyder

@JasperAustin
Copy link

Thanks again @ccordoba12 . I use Anaconda, and tried your 1st command twice but still got the following error:
C:\Users\U608025>conda update spyder
Fetching package metadata ...

CondaHTTPError: HTTP None None for url
Elapsed: None

An HTTP error occurred when trying to retrieve this URL.
ConnectTimeout(MaxRetryError("HTTPSConnectionPool(host='repo.continuum.io', port
=443): Max retries exceeded with url: /pkgs/free/win-64/repodata.json.bz2 (Cause
d by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConn
ection object at 0x0000000006D19A90>, 'Connection to repo.continuum.io timed out
. (connect timeout=9.15)'))",),)

@aflugge
Copy link

aflugge commented Oct 16, 2017

I have run

pip install -U spyder

But that installed Spyder 3.1.2, not 3.2. (On Ubuntu 16.04 LTS)

@ghost
Copy link

ghost commented Nov 22, 2017

Hi everybody !

I have a little issue with my spyder. I first apologize to write my problem here ! That is not so important but I wish someone could help me ^^
Actually, when I open Spyder I have plenty of variables in the explorer such as ScalarType, cast ect...
Is there an esay way to prevent these variables to show up ?

Thank you a lot !

@Prikers
Copy link
Contributor

Prikers commented Nov 22, 2017

@ldesmet on the upper right corner of the variable explorer plugin there is a cog menu. In there, there are options to hide some variables such as:

  • Private references (variable names starting with _)
  • All upper-case references
  • Unsupported data types

Do these options fit your needs?

@ghost
Copy link

ghost commented Nov 22, 2017

Hi ! Thank you for your answer :)

Unfortunately I've already checked these boxes. I still have these variables in the variable explorer when I open Spyder (once again, not a big deal, I just delete them manually but I would like to stop doing this ^^)

Thank's again !

@Prikers
Copy link
Contributor

Prikers commented Nov 22, 2017

As soon as you open spyder (before running any script) these variables populate the variable explorer?

@ghost
Copy link

ghost commented Nov 22, 2017

Yes exactly ! I can join a picture if you want.

@jitseniesen
Copy link
Member

@ldesmet It looks like the IPython console runs some code as soon as you open it, possibly importing numpy. Can you open your Preferences in Spyder (in the Tools menu), click IPython console and the Graphics tab, and look whether Automatically import Pylab and Numpy modules is checked? If so, that is probably the cause. If not, other things to check are the Startup tab and Use symbolic maths under Advanced Settings.

If none of this helps, a picture would be useful.

@ghost
Copy link

ghost commented Nov 23, 2017

Hi thank you for your answer !

I've just unchecked the box "Automatically import Pylab and Numpy modules" and now I don't see these variables anymore ! That works perfectly !

Thank you both of you @Prikers and @jitseniesen :)

@addarnr
Copy link

addarnr commented Dec 4, 2017

Hello, I am new to python and spyder and I have spyder 3.2.4 with Python 3.5 installed. I have a tensorflow code that runs fine. However, I have issues with debugging since it doesn't show any variable values associated with tensorflow in the console. Please see an example 'predict' below after running the code in debug mode. 'predict is the output of a tensorflow function.

ipdb> i
9
ipdb> predict
<tf.Tensor 'Equal:0' shape=(?,) dtype=bool>

I am importing the following;
import numpy as np
import tensorflow as tf
import time
import data_helpers

Is there a workaround to show the tensorflow variable values in the console since that's important for debugging?

Thanks!

@jbanerje
Copy link

jbanerje commented Dec 29, 2017

Greetings!

I have a similar problem in the variable explorer. I am using Spyder 3.5. Please let me know if i am doing anything wrong here.

When i write the below code , I am able to see welcome_str listed as in the variable explorer

welcome_str='hello'
print(welcome_str)

Now if the write the same code using name=="main" , variable explorer is empty

#Main function
def main():
       
    #define constants here
    welcome_str='hello'
    
    #program flow
    print(welcome_str)

#Main function call
if __name__=="__main__":
    main()

@openmindednewby
Copy link

I have experience the same bug on my attempt to implement the following code at the beginning of the script as an alternative to manually using %reset in the IPython console to clear the variable explorer

from IPython import get_ipython
get_ipython().magic('reset -sf')

debuged when imported some data from the GUI manualy

@JesterEE
Copy link

I was also having this issue. I traced it to the use of an IPython startup script. I was doing some variable clean-up at the end and del get_ipython was apparently ruining the connection to the Variable Explorer. Keeping get_ipython in the scope seems to make it work correctly.

@ccordoba12
Copy link
Member

get_ipython was apparently ruining the connection to the Variable Explorer. Keeping get_ipython in the scope seems to make it work correctly.

Yep, get_ipython is very important, not only for Spyder but for IPython. So please don't remove it.

@jagadishkt
Copy link

jagadishkt commented Aug 16, 2018

capture
the texts are not displaying in values column of clean_answer, how to resolve this

@ccordoba12
Copy link
Member

@jagadishkt, please open a new issue about your problem instead of posting in old and closed ones. Also, please post a simple code we can use to reproduce your error.

@nitinmuteja
Copy link

@ccordoba12 thanks. It helped

@reinhub-1
Copy link

I have the same issue with Spyder 3.1.2 and Python 3.6. Functions are not executed properly - I see them running, but nothing is returned. This is also the case with dummy-test functions (like a+b return c).

@yogeshkkolte
Copy link

I was having same issue with spyder 3.3.6 . I uninstalled numpy, spyder and reinstalled both then problem has resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests