
- Jupyter 教程
- Jupyter - 首页
- IPython
- IPython - 简介
- IPython - 安装
- IPython - 入门
- 运行和编辑 Python 脚本
- IPython - 历史命令
- IPython - 系统命令
- IPython - 命令行选项
- 动态对象内省
- IPython - IO 缓存
- 将 IPython 设置为默认 Python 环境
- 导入 Python Shell 代码
- IPython - 嵌入 IPython
- IPython - 魔法命令
- Jupyter
- Project Jupyter - 概述
- Jupyter Notebook - 简介
- 使用 Jupyter 在线
- 安装和入门
- Jupyter Notebook - 仪表盘
- Jupyter Notebook - 用户界面
- Jupyter Notebook - 单元格类型
- Jupyter Notebook - 编辑
- Jupyter Notebook - Markdown 单元格
- 单元格魔法函数
- Jupyter Notebook - 绘图
- 转换 Notebook
- Jupyter Notebook - IPyWidgets
- QtConsole
- QtConsole - 入门
- QtConsole - 多行编辑
- QtConsole - 内联图形
- QtConsole - 保存为 Html
- QtConsole - 多个控制台
- 连接到 Jupyter Notebook
- 使用 github 和 nbviewer
- JupyterLab
- JupyterLab - 概述
- 安装和入门
- JupyterLab - 界面
- JupyterLab - 安装 R 内核
- Jupyter 资源
- Jupyter - 快速指南
- Jupyter - 有用资源
- Jupyter - 讨论
IPython - 命令行选项
在本章中,让我们了解如何在 IPython 中使用各种命令行选项。
调用 IPython 程序
您可以使用以下选项调用 IPython 程序:
C:\python36> ipython [subcommand] [options] [-c cmd | -m mod | file] [--] [arg]
文件选项是一个带有 .py 扩展名的 Python 脚本。如果没有给出其他选项,则执行脚本并重新出现命令提示符。
C:\python36>ipython hello.py Hello IPython welcome to interactive computing
子命令和参数
IPython 命令接受以下子命令选项:
配置文件 - 创建和管理 IPython 配置文件。
内核 - 启动一个没有附加前端的内核。
定位 - 打印 IPython 目录的路径。
历史记录 - 管理 IPython 历史记录数据库。
IPython 配置文件子命令接受以下参数:
ipython profile create myprofile - 创建一个新的配置文件。
ipython profile list - 列出所有可用的配置文件。
ipython locate profile myprofile - 定位所需的配置文件。
要安装新的 IPython 内核,请使用以下命令:
Ipython kernel –install –name
要打印 IPython 目录的路径,请使用以下命令:
C:\python36>ipython locate myprofile C:\Users\acer\.ipython
此外,我们知道:
history 子命令管理 IPython 历史记录数据库。
trim 选项将 IPython 历史记录数据库缩减到最后 1000 个条目。
clear 选项删除所有条目。
IPython 的一些其他重要命令行选项列在下面:
序号 | IPython 命令和描述 |
---|---|
1 | --automagic 打开自动调用魔法命令。 |
2 | --pdb 在每次异常后启用自动调用 pdb 调试器。 |
3 | --pylab 预加载 matplotlib 和 numpy 以与默认的 matplotlib 后端进行交互式使用。 |
4 | --matplotlib 配置 matplotlib 以与默认的 matplotlib 后端进行交互式使用。 |
5 | --gui=options 启用 GUI 事件循环与 ('glut', 'gtk', 'gtk2','gtk3', 'osx', 'pyglet', 'qt', 'qt4', 'qt5', 'tk', 'wx', 'gtk2', 'qt4') 中的任何一个集成。 |
一些 IPython 命令行选项的示例用法显示在以下表格中:
序号 | IPython 命令和描述 |
---|---|
1 | ipython --matplotlib 启用 matplotlib 集成 |
2 | ipython --matplotlib=qt 启用使用 qt4 后端的 matplotlib 集成 |
3 | ipython --profile=myprofile 使用配置文件 foo 启动 |
4 | ipython profile create myprofile 使用默认配置文件创建配置文件 foo |
5 | ipython help profile 显示配置文件子命令的帮助 |
6 | ipython locate 打印 IPython 目录的路径 |
7 | ipython locate profile myprofile 打印配置文件 `myprofile` 的目录路径 |