环境
默认centos7的python版本是python2.7,并且没有安装ipython
Python3.6 安装
安装依赖
yum install xz gcc zlib zlib-devel wget sqlite-devel openssl-devel -y
# yum install readline-devel -y (不安装是无法使用删除的符号,它必须依赖于readline来实现所自己自有的命令行解析
器的交互模式中的程序控制)
官网下载源码(注意网络能ping通www.python.org)
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
并将/usr/local/python3/bin加入PATH
# vim ~/.bash_profile
#.bash_profile
# Get thealiases and functions
if[-f ~/.bashrc ]; then
.
~/.bashrc
fi
# Userspecific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
按ESC,输入:wq回车退出。修改完记得执行下面的命令,让上一步的修改生效:
# source ~/.bash_profile
为pip3的软链接(Python3.6默认安装了pip3、setuptools)
# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
检查Python3及pip3是否正常可用
# python3 -V
Python3.6.3
# pip3 -V
pip9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python3.6)
Ipython 安装
方法一:1.通过压缩包安装ipython
# wget https://pypi.python.org/packages/79/63/b671fc2bf0051739e87a7478a207bbeb45cfae3c328d38ccdd063d9e0074
/ipython-6.1.0.tar.gz#md5=1e15e1ce3f3f722da6935d7ac0e51346
2. 安装ipython#
# tar zvxf ipython-6.1.0.tar.gz
# cd ipython-6.1.0
# python3 setup.py install
3.通过pip安装ipython所有缺失模块,直至ipython运行成功
# ipython
Traceback (most recent call last):
File "/usr/local/python3/bin/ipython", line 4, in <module>
from IPython import start_ipython
File "/usr/local/python3/lib/python3.6/site-packages/IPython/__init__.py", line 54, in <module>
from .core.application import Application
File "/usr/local/python3/lib/python3.6/site-packages/IPython/core/application.py", line 23, in <module>
from traitlets.config.application import Application, catch_config_error
ModuleNotFoundError: No module named 'traitlets'
#运行ipython是提示缺少'traitlets'模块;安装提示一步步通过pip安装缺失模块
# pip3 install 'traitlets'
# pip3 install 'pygments'
# pip3 install 'pexpect'
# pip3 install 'pickleshare'
# pip3 install 'prompt_toolkit'
# pip3 install 'simplegeneric'
# ipython
Python 3.6.3 (default, May 26 2018, 10:18:59)Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]:
安装完成
方法二:直接通过pip3安装ipython
# pip3 install ipython
ipython
Python 3.6.3 (default, May 26 2018, 10:18:59)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]:
#ipython安装成功
pip3安装ipython中遇到的问题:
Could not find a version that satisfies the requirement ipython (from versions: )
No matching distribution found for ipython
#解决:以上报错无法连接资源,查看网络是否连接。