Musab Ahmad
Musab Ahmad

Reputation: 61

Spyder console not showing output

I run the following code in Spyder 4.1.1 but the console doesn't show any output :

df.head()
df.shape

Previously I had Spyder 3.7 and it worked but now after updating it is not working. I tried resetting to default settings and tried to change the console settings but nothing worked. If I used print(df.head) it works but it should work without print().

Please help. Attached is the screenshot

spyder screenshot

Upvotes: 5

Views: 33245

Answers (4)

I don't know why, but opening a new console and rerunning the code with the F9 key fixed my issue.

Upvotes: 0

Derek
Derek

Reputation: 1

First, use print(x), or plt.show() if using matplotlib.pyplot.

Then, if you find that spyder python does not give any output at (F5), change Preferences (spanner icon), select menu 'Run' and change to a different Console option, e.g. 'Execute in a dedicated console', then Run (F5).

As a newbie and very occasional user I regularly have this frustrating problem of how to run the code to get a pyplot output - I press the green play button and nothing happens! No charts, until I change those preferences.

Upvotes: -1

Paddy Popeye
Paddy Popeye

Reputation: 1814

You need to highlight what you want to run. Then run/execute the current line/s by either pressing F9, or the Run selection or current line button on the Run toolbar(the black one). It will then show output without needing to use print

Upvotes: 4

Ardweaden
Ardweaden

Reputation: 887

Try running the following in the Ipython console.

%config InteractiveShell.ast_node_interactivity='last_expr'

This is the setting description:

ZMQInteractiveShell.ast_node_interactivity=<Enum>

Current: 'last_expr'
Choices: ['all', 'last', 'last_expr', 'none', 'last_expr_or_assign']

'all', 'last', 'last_expr' or 'none', 'last_expr_or_assign' specifying which 
nodes should be run interactively (displaying output from expressions).

Upvotes: 4

Related Questions