您好,登录后才能下订单哦!
commands List all available pyenv commands local Set or show the local application-specific Python version global Set or show the global Python version shell Set or show the shell-specific Python version install Install a Python version using python-build uninstall Uninstall a specific Python version rehash Rehash pyenv shims (run this after installing executables) version Show the current Python version and its origin versions List all Python versions available to pyenv which Display the full path to an executable whence List all Python versions that contain the given executable
1.verson&versons
verson只显示当前的python版本
versons显示所有可用的python版本,当前使用的版本前带*号
[python@192.168.240.77 RINGOO-1]: ~ 127> pyenv version system (set by /home/python/.pyenv/version) [python@192.168.240.77 RINGOO-1]: ~ 0> pyenv versions * system (set by /home/python/.pyenv/version) 3.5.3 3.6.3
2. global、shell、local之间的区别:
2.1. global 全局设置
如果使用此命令,可以看到所有受到pyenv控制的窗口都受到了影响, 所以尽可能不要用root用户来安装pyenv,否则会影响到之前的系统
[python@192.168.240.77 RINGOO-1]: ~ 0> pyenv versions * system (set by /home/python/.pyenv/version) 3.5.3 3.6.3 [python@192.168.240.77 RINGOO-1]: ~ 0> pyenv global 3.5.3 [python@192.168.240.77 RINGOO-1]: ~ 0> pyenv versions system (set by /home/python/.pyenv/version) * 3.5.3 3.6.3 [python@192.168.240.77 RINGOO-1]: ~ 130> python -V Python 3.5.3
2. 2 shell 会话设置(只影响当前的会话)
【会话1 】 :
[python@192.168.240.77 RINGOO-1]: ~ 130> pyenv version system (set by /home/python/.pyenv/version) [python@192.168.240.77 RINGOO-1]: ~ 0> pyenv shell 3.5.3 [python@192.168.240.77 RINGOO-1]: ~ 0> pyenv versions system * 3.5.3 (set by PYENV_VERSION environment variable) 3.6.3 [python@192.168.240.77 RINGOO-1]: ~ 0> python -V Python 3.5.3
可以看到会话1的pyenv和python显示版本均为3.5.3
【会话2 】 :
[python@RINGOO-1 3.5.3]$ pyenv versions * system (set by /home/python/.pyenv/version) 3.5.3 3.6.3 [python@RINGOO-1 3.5.3]$ python -V Python 2.6.6
可以看到新打开的会话是Python 2.6.6,并没有受到影响,所以shell只会影响到当前的会话,一旦这个会话结束,则一切失效
2. 3 local 本地设置(只影响所在文件夹)
新建文件目录test1/test2
mkdir -p test1/test2
并查看当前test2目录中的版本
[python@192.168.240.77 RINGOO-1]: ~ 0> mkdir -p test1/test2 [python@192.168.240.77 RINGOO-1]: ~ 0> ls test1 [python@192.168.240.77 RINGOO-1]: ~ 0> cd test1/test2 [python@192.168.240.77 RINGOO-1]: ~/test2 0> pyenv versions * system 3.5.3 (set by PYENV_VERSION environment variable) 3.6.3 [python@192.168.240.77 RINGOO-1]: ~/test2 0> python -V Python 2.6.6 [python@192.168.240.77 RINGOO-1]: ~/test2 0>
可以看到目前文件夹test2中的版本为:
pyenv system
python 2.6.6
使用local命令:
[python@192.168.240.77 RINGOO-1]: ~/test2 130> pyenv local 3.5.3
[python@192.168.240.77 RINGOO-1]: ~/test2 0> pyenv versions system * 3.5.3 (set by PYENV_VERSION environment variable) 3.6.3 [python@192.168.240.77 RINGOO-1]: ~/test2 0> python -V Python 3.5.3
可以看到test2文件夹中的版本被改为了:
pyenv 3.5.3
python 3.5.3
而进入上一级目录(其他目录均可)
[python@192.168.240.77 RINGOO-1]: ~/test2 0> cd .. [python@192.168.240.77 RINGOO-1]: ~/test1 0> pyenv versions * system 3.5.3 (set by PYENV_VERSION environment variable) 3.6.3 [python@192.168.240.77 RINGOO-1]: ~/test1 0> python -V Python 2.6.6
可以看到目前文件夹test1中的版本依旧为:
pyenv system
python 2.6.6
所以 local命令只会对当前的文件夹和其子目录中的版本起作用 ,其他的目录不起作用
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。