📜  IPython-命令行选项

📅  最后修改于: 2020-11-08 07:03:58             🧑  作者: Mango


在本章中,让我们了解如何在IPython中使用各种命令行选项。

调用IPython程序

您可以使用以下选项来调用IPython程序-

C:\python36> ipython [subcommand] [options] [-c cmd | -m mod | file] [--] [arg]

file选项是扩展名为.py的Python脚本。如果未给出其他选项,则脚本将被执行并重新出现命令提示符。

C:\python36>ipython hello.py
Hello IPython
welcome to interactive computing

子命令和参数

IPython命令接受以下子命令选项-

  • 配置文件-创建和管理IPython配置文件。

  • 内核-启动没有附加前端的内核。

  • 定位-打印IPython目录的路径。

  • 历史记录-管理IPython历史记录数据库。

IPython配置文件子命令接受以下参数-

  • ipython配置文件创建myprofile-创建一个新的配置文件。

  • ipython配置文件列表-列出所有可用的配置文件。

  • ipython查找配置文件myprofile-找到所需的配置文件。

要安装新的IPython内核,请使用以下命令-

Ipython kernel –install –name

要打印IPython目录的路径,请使用以下命令-

C:\python36>ipython locate myprofile
C:\Users\acer\.ipython

此外,我们知道-

  • history子命令管理IPython历史数据库。

  • trim选项将IPython历史记录数据库减少到最后1000个条目。

  • clear选项将删除所有条目。

下面列出了IPython的其他一些重要命令行选项-

Sr.No. IPython Command & Description
1

–automagic

Turn on the auto calling of magic commands.

2

–pdb

Enable auto calling the pdb debugger after every exception.

3

–pylab

Pre-load matplotlib and numpy for interactive use with the default matplotlib backend.

4

–matplotlib

Configure matplotlib for interactive use with the default matplotlib backend.

5

–gui=options

Enable GUI event loop integration with any of (‘glut’, ‘gtk’, ‘gtk2′,’gtk3’, ‘osx’, ‘pyglet’, ‘qt’, ‘qt4’, ‘qt5’, ‘tk’, ‘wx’, ‘gtk2’, ‘qt4’).

下表显示了一些IPython命令行选项的示例用法-

Sr.No. IPython Command & Description
1

ipython –matplotlib

enable matplotlib integration

2

ipython –matplotlib=qt

enable matplotlib integration with qt4 backend

3

ipython –profile=myprofile

start with profile foo

4

ipython profile create myprofile

create profile foo w/ default config files

5

ipython help profile

show the help for the profile subcmd

6

ipython locate

print the path to the IPython directory

7

ipython locate profile myprofile

print the path to the directory for profile `myprofile`