1[root@web ~]# cat /etc/redhat-release
2CentOS Linux release 7.6.1810 (Core)
3[root@web ~]# uname -a
4Linux web 3.10.0-957.21.3.el7.x86_64 #1 SMP Tue Jun 18 16:35:19 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
1[root@web ~]# curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
1[root@web ~]# cd /root
2[root@web ~]# cp .bash_profile .bash_profile.bak
3[root@web ~]# vim .bash_profile
4#pyenv
5export PATH="~/.pyenv/bin:$PATH"
6eval "$(pyenv init -)"
7eval "$(pyenv virtualenv-init -)"
8[root@web ~]# source .bash_profile
1[root@web ~]# python -V
2Python 2.7.5
1[root@web ~]# pyenv -v
2pyenv 1.2.15
1[root@web ~]# pyenv update
1[root@web ~]# pyenv install --list
安装Python3.6.4、2.7.2和3.6.7
1[root@web ~]# pyenv install 3.6.4
2[root@web ~]# pyenv install 2.7.2
3[root@web ~]# pyenv install 3.6.7
1[root@web ~]# pyenv versions
2* system (set by /root/.pyenv/version)
3 2.7.2
4 3.6.4
5 3.6.7
6[root@web ~]#
1[root@web ~]# cd /root/
2[root@web ~]# pyenv virtualenv 3.6.4 root364
3[root@web ~]# pyenv activate root364
4[root@web ~]# pyenv global 3.6.4
5(root364) [root@web ~]# python -V
6Python 3.6.4
1(root364) [root@web ~]# pyenv deactivate
2[root@web ~]#
1[root@web ~]# pyenv virtualenv-delete root364
2pyenv-virtualenv: remove /root/.pyenv/versions/3.6.4/envs/root364? y
3[root@web ~]#
设置/tmp目录的Python环境为python3.6.7
1[root@web ~]# cd /tmp/
2[root@web tmp]# pyenv virtualenv 3.6.7 tmp367
3Looking in links: /tmp/tmpshtqhsk6
4Requirement already satisfied: setuptools in /root/.pyenv/versions/3.6.7/envs/tmp367/lib/python3.6/site-packages (39.0.1)
5Requirement already satisfied: pip in /root/.pyenv/versions/3.6.7/envs/tmp367/lib/python3.6/site-packages (10.0.1)
6[root@web tmp]# pyenv activate tmp367
7[root@web tmp]# pyenv local tmp367
8(tmp367) [root@web tmp]# python -V
9Python 3.6.7
10(tmp367) [root@web tmp]#