Centos 7安装python3.6及ipython6

环境

默认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)

# wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz

解压文件

# tar zxvf Python-3.6.3.tar.xz

进入目录安装编译

# cd Python-3.6.3

# ./configure --prefix=/usr/local/python3

# make && make install

建立python3的软链

# 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

检查Python3pip3是否正常可用

# 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

#解决:以上报错无法连接资源,查看网络是否连接。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值