commandsListallavailablepyenvcommandslocalSetorshowthelocalapplication-specificPythonversionglobalSetorshowtheglobalPythonversionshellSetorshowtheshell-specificPythonversioninstallInstallaPythonversionusingpython-builduninstallUninstallaspecificPythonversionrehashRehashpyenvshims(runthisafterinstallingexecutables)versionShowthecurrentPythonversionanditsoriginversionsListallPythonversionsavailabletopyenvwhichDisplaythefullpathtoanexecutablewhenceListallPythonversionsthatcontainthegivenexecutable

1.verson&versons

verson只显示当前的python版本

versons显示所有可用的python版本,当前使用的版本前带*号

[python@192.168.240.77RINGOO-1]:~127>pyenvversionsystem(setby/home/python/.pyenv/version)[python@192.168.240.77RINGOO-1]:~0>pyenvversions*system(setby/home/python/.pyenv/version)3.5.33.6.3


2.global、shell、local之间的区别:

2.1.global 全局设置

如果使用此命令,可以看到所有受到pyenv控制的窗口都受到了影响,所以尽可能不要用root用户来安装pyenv,否则会影响到之前的系统

[python@192.168.240.77RINGOO-1]:~0>pyenvversions*system(setby/home/python/.pyenv/version)3.5.33.6.3[python@192.168.240.77RINGOO-1]:~0>pyenvglobal3.5.3[python@192.168.240.77RINGOO-1]:~0>pyenvversionssystem(setby/home/python/.pyenv/version)*3.5.33.6.3[python@192.168.240.77RINGOO-1]:~130>python-VPython3.5.3

2. 2 shell 会话设置(只影响当前的会话)

【会话1】:

[python@192.168.240.77RINGOO-1]:~130>pyenvversionsystem(setby/home/python/.pyenv/version)[python@192.168.240.77RINGOO-1]:~0>pyenvshell3.5.3[python@192.168.240.77RINGOO-1]:~0>pyenvversionssystem*3.5.3(setbyPYENV_VERSIONenvironmentvariable)3.6.3[python@192.168.240.77RINGOO-1]:~0>python-VPython3.5.3

可以看到会话1的pyenv和python显示版本均为3.5.3

【会话2】:

[python@RINGOO-13.5.3]$pyenvversions*system(setby/home/python/.pyenv/version)3.5.33.6.3[python@RINGOO-13.5.3]$python-VPython2.6.6

可以看到新打开的会话是Python 2.6.6,并没有受到影响,所以shell只会影响到当前的会话,一旦这个会话结束,则一切失效

2. 3 local 本地设置(只影响所在文件夹)

新建文件目录test1/test2

mkdir-ptest1/test2

并查看当前test2目录中的版本

[python@192.168.240.77RINGOO-1]:~0>mkdir-ptest1/test2[python@192.168.240.77RINGOO-1]:~0>lstest1[python@192.168.240.77RINGOO-1]:~0>cdtest1/test2[python@192.168.240.77RINGOO-1]:~/test20>pyenvversions*system3.5.3(setbyPYENV_VERSIONenvironmentvariable)3.6.3[python@192.168.240.77RINGOO-1]:~/test20>python-VPython2.6.6[python@192.168.240.77RINGOO-1]:~/test20>

可以看到目前文件夹test2中的版本为:

pyenv system

python 2.6.6

使用local命令:

[python@192.168.240.77RINGOO-1]:~/test2130>pyenvlocal3.5.3

[python@192.168.240.77RINGOO-1]:~/test20>pyenvversionssystem*3.5.3(setbyPYENV_VERSIONenvironmentvariable)3.6.3[python@192.168.240.77RINGOO-1]:~/test20>python-VPython3.5.3

可以看到test2文件夹中的版本被改为了:

pyenv 3.5.3

python3.5.3

而进入上一级目录(其他目录均可)

[python@192.168.240.77RINGOO-1]:~/test20>cd..[python@192.168.240.77RINGOO-1]:~/test10>pyenvversions*system3.5.3(setbyPYENV_VERSIONenvironmentvariable)3.6.3[python@192.168.240.77RINGOO-1]:~/test10>python-VPython2.6.6

可以看到目前文件夹test1中的版本依旧为:

pyenv system

python 2.6.6

所以local命令只会对当前的文件夹和其子目录中的版本起作用,其他的目录不起作用