How to run IPython script from the command line - syntax error with magic functions,%

I want to start IPython from the command line. However, I get a syntax error in the first line by importing pylab with the magic function %pylab , giving a syntax error in%. The command I use is just ipython -i script.py .

Any ideas how to solve this?

+6
source share
1 answer

You need to specify the script.ipy file. When it ends in .ipy, it may contain ipython syntax.

From ipython --help :

 Usage ipython [subcommand] [options] [files] If invoked with no options, it executes all the files listed in sequence and exits, use -i to enter interactive mode after running the files. Files ending in .py will be treated as normal Python, but files ending in .ipy can contain special IPython syntax (magic commands, shell expansions, etc.) 
+6
source

All Articles