目录
  1. 1. Ipython 简介
  2. 2. 配置使用国内源安装第三方模块
    1. 2.1. 创建配置文件
  3. 3. 安装 Ipython
    1. 3.1. 安装 python-devel
    2. 3.2. 安装 ipython
    3. 3.3. 启动 ipython
  4. 4. 解决:
    1. 4.1. 退出 ipython
Linux安装Ipython 交互式解释器

Ipython 简介

IPython外加一个文本编辑器

Windows系统下是IPython加notepad++,Linux系统下是IPython加vim配合使用,写起代码来体验很流畅,很容易获取到写代码时候的那种“流体验”。

IPython的设计目的是在交互式计算和软件开发这两个方面最大化地提高生产力,它鼓励一种“执行-探索”的工作模式,支持matplotlib等库的绘图操作。同时IPython还提供一个基于WEB的交互式浏览器开发环境(Jupyter Notebook),用起来也很不错。

配置使用国内源安装第三方模块

创建配置文件

配置 pip3 使用国内源

1
2
3
mkdir ~/.pip
vi ~/.pip/pip.conf
# Windows 下使用 pip.ini

写入如下内容:

1
2
[global]
index-url=https://mirrors.aliyun.com/pypi/simple

豆瓣源: https://pypi.douban.com/simple/

阿里源: https://mirrors.aliyun.com/pypi/simple

清华: https://pypi.tuna.tsinghua.edu.cn/simple

阿里云: http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学: http://pypi.hustunique.com/

山东理工大学: http://pypi.sdutlinux.org/

示例:
比如安装一个执行远程主机命令的模块

1
2
3
4
5
6
7
8
9
[root@newrain ~]# pip3 install paramiko
Collecting paramiko
Downloading https://mirrors.aliyun.com/pypi/packages/4b/80/74dace9e48b0ef923633dfb5e48798f58a168e4734bca8ecfaf839ba051a/paramiko-2.6.0-py2.py3-none-any.whl (199kB)
100% |████████████████████████████████| 204kB 2.3MB/s
Collecting bcrypt>=3.1.3 (from paramiko)
Downloading https://mirrors.aliyun.com/pypi/packages/8b/1d/82826443777dd4a624e38a08957b975e75df859b381ae302cfd7a30783ed/bcrypt-3.1.7-cp34-abi3-manylinux1_x86_64.whl (56kB)
100% |████████████████████████████████| 61kB 3.1MB/s
Collecting pynacl>=1.0.1 (from paramiko)
...

安装 Ipython

安装 python-devel

​ python-dev或python-devel称为是python的开发包,其中包括了一些用C/Java/C#等编写的python扩展在编译的时候依赖的头文件等信息。

比如:我们在编译一个用C语言编写的python扩展模块时,因为里面会有#include<Python.h>等这样的语句,因此我们就需要先安装python-devel开发包

执行以下命令安装即可(需要有 epel 源支持):

1
yum -y install python-devel

安装 ipython

1
pip3 install ipython

启动 ipython

1
2
3
4
5
6
[root@nginx2-8 ~]# ipython
Python 3.7.3 (default, Oct 8 2019, 15:49:02)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

当pip安装ipython, bpython后, 直接执行ipython or bpython会报错:*python: command not found

解决:

环境变量问题,设置别名就好。

1
`alias ipython=``'python3 -m IPython'``alias bpython=``'python3 -m bpython'`

退出 ipython

1
2
3
4
5
6
7
[root@nginx2-8 ~]# ipython
Python 3.7.3 (default, Oct 8 2019, 15:49:02)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: exit
[root@nginx2-8 ~]#

文章作者: GZ
文章链接: https://gz1903.github.io/2019/10/09/Linux安装Ipython-交互式解释器/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 GZ's Blog
打赏
  • 微信
  • 支付宝

评论