IPython magics no longer work in Spyder 4
See original GitHub issueIssue Report Checklist
- Searched the issues page for similar reports
- Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
- Reproduced the issue after updating with
conda update spyder
(orpip
, if not using Anaconda) - Could not reproduce inside
jupyter qtconsole
(if console-related) - Tried basic troubleshooting (if a bug/error)
- Restarted Spyder
- Reset preferences with
spyder --reset
- Reinstalled the latest version of Anaconda
- Tried the other applicable steps from the Troubleshooting Guide
- Completed the Problem Description, Steps to Reproduce and Version sections below
Problem Description
If we have ipython magic commands in the editor, running them with shift+enter no longer works with Spyder 4
%who print
# %%
runcell(0, 'C:/users/mark/git/vispy/vispy/app/untitled1.py')
File "C:\users\mark\git\vispy\vispy\app\untitled1.py", line 1
%who print
^
SyntaxError: invalid syntax
What is the expected output? What do you see instead?
It used to work in Spyder 3, has the decision been made to revert things?
Versions
- Spyder version: 4.0.0
- Python version: 3.7.3 64-bit
- Qt version: 5.12.5
- PyQt version: 5.12.3
- Operating System name/version: Windows / Linux
Issue Analytics
- State:
- Created 4 years ago
- Comments:39 (25 by maintainers)
Top Results From Across the Web
How to use IPython magic commands within the Spyder editor?
Firstly, you can open the ipython qtconsloe in the CMD. If you don't open it, the model of ipython is lack in the...
Read more >Built-in magic commands — IPython 8.7.0 documentation
To work properly, Magics must use a syntax element which is not valid in the underlying language. For example, the IPython kernel uses...
Read more >Interactive work — rpy2 3.5.4 documentation
This module contains a number of experimental features, some of them no longer necessary since the “R magic” extension for ipython. They are...
Read more >rmagic — IPython 2.4.2-maint documentation
The rmagic extension has been moved to rpy2 as rpy2.interactive.ipython . Magic command interface for interactive work with R via rpy2. Note. The...
Read more >Re: [spyder] %paste not working in IPython kernel
%paste magic is only defined for the terminal version of IPython, not for its graphical frontends (i.e. the notebook and qtconsole) because
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
IPython magics are not valid Python code, so we decided to not support them anymore in Python files. That will avoid the common problem of files that work in Spyder but not outside of it.
If you want to keep using them, you need to run them like
I think @impact27 added support for
.ipy
files, i.e. IPython script files. In those files you can use magics freely.I guess I’m trying to say that I’ve seen 4/4 users of Spyder 3 migrate to Spyder 4 and been tripped up by this behavior.
People posting on this thread are to say the least, pretty advanced users of python/spyder. This isn’t the norm.
I agree with your desire to help people write better code, but I would consider this a breaking change in the user experience, and some kind of guidance would be helpful.
It seems that you would prefer users not to use
Copy full cell contents to the console when running code cells
, but rather to save their files asipy
to keep them portable.A little guidance will go a long way.
Changing how code is excuted (copied or now) can be ignored. The fact that scripts developed in spyder no longer work with spyder is not really fun.