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
成都創(chuàng)新互聯(lián)公司專注于沙灣企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站設(shè)計(jì),購物商城網(wǎng)站建設(shè)。沙灣網(wǎng)站建設(shè)公司,為沙灣等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站建設(shè),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)
verson只顯示當(dāng)前的python版本
versons顯示所有可用的python版本,當(dāng)前使用的版本前帶*號(hào)
[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之間的區(qū)別:
2.1. global 全局設(shè)置
如果使用此命令,可以看到所有受到pyenv控制的窗口都受到了影響, 所以盡可能不要用root用戶來安裝pyenv,否則會(huì)影響到之前的系統(tǒng)
[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 會(huì)話設(shè)置(只影響當(dāng)前的會(huì)話)
【會(huì)話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
可以看到會(huì)話1的pyenv和python顯示版本均為3.5.3
【會(huì)話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
可以看到新打開的會(huì)話是Python 2.6.6,并沒有受到影響,所以shell只會(huì)影響到當(dāng)前的會(huì)話,一旦這個(gè)會(huì)話結(jié)束,則一切失效
2. 3 local 本地設(shè)置(只影響所在文件夾)
新建文件目錄test1/test2
mkdir -p test1/test2
并查看當(dāng)前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
而進(jìn)入上一級(jí)目錄(其他目錄均可)
[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命令只會(huì)對(duì)當(dāng)前的文件夾和其子目錄中的版本起作用 ,其他的目錄不起作用