【问题标题】:How to run IPython script from the command line - syntax error with magic functions, %如何从命令行运行 IPython 脚本 - 魔术函数的语法错误,%
【发布时间】:2014-02-27 18:18:55
【问题描述】:

我想从命令行运行 IPython。但是,我在第一行遇到语法错误,使用魔术函数 %pylab 导入 pylab 在 %.我使用的命令只是ipython -i script.py

有什么办法解决这个问题吗?

【问题讨论】:

    标签: ipython ipython-magic


    【解决方案1】:

    您需要将文件命名为 script.ipy。当它以 .ipy 结尾时,它可以包含 ipython 语法。

    来自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.)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-08
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 2013-01-02
      • 2012-02-07
      相关资源
      最近更新 更多