前提:
1、变更RHEL6.7源为 CENTOS 6源。可参考文档RHEL6更换CentOS源
2、原因:RHEL6可能与CentOS6不同。
3、本文是在此前提下配置,如出现错误提示,请先满足上述条件后安装。切勿盲目安装配置。
开始配置安装pyenv:
# yum groupinstall "Development tools"
# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel \
sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
安装pyenv
# git clone git://github.com/yyuu/pyenv.git .pyenv
配置pyenv:
# vim /etc/profile.d/pyenv.sh
如下代码:
#!/bin/bash
############################################
# Name : /etc/profile.d/pyenv.sh
# Author : Hisea_Y
# Date : 20 Mar 2017
############################################
# Define The Environment Variable
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
执行:
# source /etc/profile.d/pyenv.sh
使用pyenv安装Python:
# pyenv versions #查看当前安装版本
* system (set by /root/.pyenv/version)
# python -V #查看系统所安装的版本
Python 2.6.6
查看可安装的Python版本:
# pyenv install -l | more
选择安装最新的2.7.13 以及 较新的3.5.3 (3.6.0 部分插件不支持,当然可以一并安装)
# pyenv install 2.7.13
# pyenv install 3.5.3
# pyenv install 3.6.0
pip安装与配置
# yum install python-pip
使用pip安装IPython
# pyenv global 3.5.3
# pyenv versions
system
2.7.13
* 3.5.3 (set by /root/.pyenv/version)
3.6.0
# pip install ipython
# ipython
In [1]: print ('hello world')
hello world
In [2]: 1/2
Out[2]: 0.5
In [3]: exit()
# pyenv global 2.7.13
# pyenv version
2.7.13 (set by /root/.pyenv/version)
# pip install ipython
# ipython
In [1]: print 'hello world'
hello world
In [2]: 1/2
Out[2]: 0
In [3]: exit()