Anaconda Spyder shortcuts Ctrl+Enter and Shift+Enter are not working
- You need to use comments of the form
#%%
to break your files in cells, which are blocks of code you can evaluate independently. Then Cmd+Enter and Shift+Enter will work as expected, i.e. they will evaluate the current cell and stay on it or move to the next one, respectively. - About your second question, if you are running a file with the Run command (what you get when you press F5), you need to change your last line to
print(x)
, because Run doesn't print by default.
Matthias
Instrumental in successful development of GUI components for client-server multi-user systems. Deployed advanced technologies such as UML, Microsoft .NET, OpenGL/DirectX and Microsoft SQL Server.
Updated on June 04, 2022Comments
-
Matthias over 1 year
Sorry for this noob question. I recently installed Anaconda Spyder UI for Python on MacOS. Within Spyder you see three windows, the python file (source code), the variable explorer and the IPython console.
I got two problems:
First, the shortcuts do not work. For instance: Run Cell = CTRL+ENTER and Run Cell and Advance is SHIFT+ENTER. But does not work.
Second, the output of the IPython console does not work. Let's assume the following code:
import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset dataset = pd.read_csv('Data.csv') x = dataset.iloc[:, :-1].values y = dataset.iloc[:, 3].values x
Then the last line should print x as output onto the IPython console. But instead I get only this:
In [1]: runfile('/Users/guest/Development/data.py', wdir='/Users/guest/Development/')
And no Out [1]. Question: What am I doing wrong? I couldn't locate anything in the preferences dialog.
-
Matthias over 6 yearsby the way: one can type in the IPython console just to print variables to the output. Saves you from using print(x) in code.
-
Carlos Cordoba over 6 yearsYep, that's true too.
-
Admin over 2 years@CarlosCordoba you guys shouldn't change stuff like that; this is a high level programming language with an ide build for noobs, let's keep it that way yes?
-
Carlos Cordoba over 2 yearsIf you're talking about cells, the convention I mentioned above is now used in Pycharm and Vscode.
-
trianta2 almost 2 yearsuser12621047 should speak for himself. The cell syntax and usage is great, Carlos.