安装pyenv版本管理

系统:Centos7.4

  安装pyenv是为了更好的管理python的版本。

在进行安装操作之前,首先使用普通用户test,进行操作,如下:

#安装之前先安装依赖的库
[test@localhost ~]$ sudo yum -y install git gcc* make patch gdbm-devel openssl-devel sqlite-devel zlib-devel bz-devel readline-devel
[test@localhost ~]$ curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
#修改,在文件末尾配置环境变量
[test@localhost ~]$vim ~/.bash_profile
export PATH
export PATH="/home/test/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
[test@localhost ~]$sourse ~/.bash_profile
#查看由pyenv安装的python版本
[test@localhost ~]$ pyenv versions
#安装3.5.2的版本
[test@localhost ~]$ pyenv install 3.5.2
[test@localhost ~]$ pyenv versions
* system (set by /home/test/.pyenv/version)
  3.5.2
#查看pyenv的命令使用:

[test@localhost ~]$ pyenv help

此时python3.5.2已经安装完成。

#此时执行命令python,还是2.7.5的版本
[test@localhost opt]$ python
Python 2.7.5 (default, Apr 11 2018, 07:36:10) 
[test@localhost ~]$ pyenv local 3.5.2
[test@localhost ~]$ python
Python 3.5.2 (default, May 16 2018, 21:06:26) 
#此时python已经为3.5.2,但是仅限于/home/test/下的目录
原文地址:https://www.cnblogs.com/wzhuo/p/9048339.html