標籤:
自動安裝pyenv$ curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash [[email protected] ~]# curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 2087 100 2087 0 0 1646 0 0:00:01 0:00:01 --:--:-- 1647正複製到 ‘/root/.pyenv‘...remote: Counting objects: 11943, done.remote: Total 11943 (delta 0), reused 0 (delta 0), pack-reused 11943接收對象中: 100% (11943/11943), 2.10 MiB | 577.00 KiB/s, done.處理 delta 中: 100% (8302/8302), done.正複製到 ‘/root/.pyenv/plugins/pyenv-doctor‘...remote: Counting objects: 26, done.remote: Total 26 (delta 0), reused 0 (delta 0), pack-reused 26接收對象中: 100% (26/26), 45.50 KiB | 46.00 KiB/s, done.處理 delta 中: 100% (10/10), done.正複製到 ‘/root/.pyenv/plugins/pyenv-installer‘...remote: Counting objects: 202, done.remote: Total 202 (delta 0), reused 0 (delta 0), pack-reused 202接收對象中: 100% (202/202), 3.30 MiB | 315.00 KiB/s, done.處理 delta 中: 100% (95/95), done.正複製到 ‘/root/.pyenv/plugins/pyenv-update‘...remote: Counting objects: 29, done.remote: Total 29 (delta 0), reused 0 (delta 0), pack-reused 29接收對象中: 100% (29/29), 4.65 KiB | 0 bytes/s, done.處理 delta 中: 100% (10/10), done.正複製到 ‘/root/.pyenv/plugins/pyenv-virtualenv‘...remote: Counting objects: 1666, done.remote: Compressing objects: 100% (4/4), done.remote: Total 1666 (delta 0), reused 0 (delta 0), pack-reused 1662接收對象中: 100% (1666/1666), 453.25 KiB | 160.00 KiB/s, done.處理 delta 中: 100% (1129/1129), done.正複製到 ‘/root/.pyenv/plugins/pyenv-which-ext‘...remote: Counting objects: 26, done.remote: Total 26 (delta 0), reused 0 (delta 0), pack-reused 26接收對象中: 100% (26/26), 4.38 KiB | 0 bytes/s, done.處理 delta 中: 100% (10/10), done. WARNING: seems you still have not added ‘pyenv‘ to the load path. # Load pyenv automatically by adding# the following to ~/.bash_profile: export PATH="/root/.pyenv/bin:$PATH"eval "$(pyenv init -)"eval "$(pyenv virtualenv-init -)" pyenv versions檢測版本[[email protected] ~]# pyenv versions* system (set by /root/.pyenv/version)帶星號的表示啟用的 查看可以安裝的版本[[email protected] ~]# pyenv install --listAvailable versions: 2.1.3 2.2.3 2.3.7 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.6.6 2.6.7 2.6.8 2.6.9 2.7-dev 2.7 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.10 2.7.11 3.0.1 3.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2-dev 3.2 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.3-dev 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.4.0 3.4-dev 3.4.1 3.4.2 3.4.3 3.4.4 3.5.0 3.5-dev 3.5.1 3.6-dev anaconda-1.4.0 anaconda-1.5.0 anaconda-1.5.1 anaconda-1.6.0 anaconda-1.6.1 anaconda-1.7.0 anaconda-1.8.0 anaconda-1.9.0 anaconda-1.9.1 anaconda-1.9.2 anaconda-2.0.0 anaconda-2.0.1 anaconda-2.1.0 anaconda-2.2.0 anaconda-2.3.0 anaconda-2.4.0 anaconda2-2.4.0 anaconda2-2.4.1 anaconda3-2.0.0 anaconda3-2.0.1 anaconda3-2.1.0 anaconda3-2.2.0 anaconda3-2.3.0 anaconda3-2.4.0 anaconda3-2.4.1 ironpython-dev ironpython-2.7.4 ironpython-2.7.5 jython-dev jython-2.5.0 jython-2.5-dev jython-2.5.1 jython-2.5.2 jython-2.5.3 jython-2.5.4-rc1 jython-2.7.0 jython-2.7.1b1 jython-2.7.1b2 miniconda-latest miniconda-2.2.2 miniconda-3.0.0 miniconda-3.0.4 miniconda-3.0.5 miniconda-3.3.0 miniconda-3.4.2 miniconda-3.7.0 miniconda-3.8.3 miniconda-3.9.1 miniconda-3.10.1 miniconda-3.16.0 miniconda-3.18.3 miniconda2-latest miniconda2-3.18.3 miniconda2-3.19.0 miniconda3-latest miniconda3-2.2.2 miniconda3-3.0.0 miniconda3-3.0.4 miniconda3-3.0.5 miniconda3-3.3.0 miniconda3-3.4.2 miniconda3-3.7.0 miniconda3-3.8.3 miniconda3-3.9.1 miniconda3-3.10.1 miniconda3-3.16.0 miniconda3-3.18.3 miniconda3-3.19.0 pypy-c-jit-latest pypy-c-nojit-latest pypy-dev pypy-stm-2.3 pypy-portable-2.3.1 pypy-portable-2.4 pypy-portable-2.5 pypy-portable-2.5.1 pypy-stm-2.5.1 pypy-portable-2.6 pypy-portable-2.6.1 pypy-portable-4.0 pypy-portable-4.0.1 pypy-1.5-src pypy-1.5 pypy-1.6 pypy-1.7-dev pypy-1.7 pypy-1.8-dev pypy-1.8 pypy-1.9-dev pypy-1.9 pypy-2.0-dev pypy-2.0-src pypy-2.0 pypy-2.0.1-src pypy-2.0.1 pypy-2.0.2-src pypy-2.0.2 pypy-2.1-src pypy-2.1 pypy-2.2-src pypy-2.2 pypy-2.2.1-src pypy-2.2.1 pypy-2.3-src pypy-2.3 pypy-2.3.1-src pypy-2.3.1 pypy-2.4.0-src pypy-2.4.0 pypy-2.4-beta1-src pypy-2.4-beta1 pypy-2.5.0-src pypy-2.5.0 pypy-2.5.1-src pypy-2.5.1 pypy-2.6.0-src pypy-2.6.0 pypy-2.6.1-src pypy-2.6.1 pypy-4.0.0-src pypy-4.0.0 pypy-4.0.1-src pypy-4.0.1 pypy3-dev pypy3-portable-2.3.1 pypy3-portable-2.4 pypy3-2.3.1-src pypy3-2.3.1 pypy3-2.4.0-src pypy3-2.4.0 stackless-dev stackless-2.7-dev stackless-2.7.2 stackless-2.7.3 stackless-2.7.4 stackless-2.7.5 stackless-2.7.6 stackless-2.7.7 stackless-2.7.8 stackless-3.2-dev stackless-3.2.2 stackless-3.2.5 stackless-3.3-dev stackless-3.3.5 stackless-3.4.1pyenv install -v 3.5.1安裝3.5.1版本,-v顯示細節安裝失敗,提示Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS yum install openssl openssl-devel再次安裝 [[email protected] ~]# pyenv versions* system (set by /root/.pyenv/version) 3.5.1成功安裝 pyenv uninstall 可以卸載一個版本pyenv rehash
為所有已安裝的可執行檔 (如:~/.pyenv/versions/*/bin/*) 建立 shims,因此,每當你增刪了 Python 版本或帶有可執行檔的包(如 pip)以後,都應該執行一次本命令
$ pyenv install 2.7.3$ pyenv rehash
pyenv global
設定全域的 Python 版本,通過將版本號碼寫入 ~/.pyenv/version 檔案的方式。
$ pyenv global3.4.0
pyenv local
設定面向程式的本地版本,通過將版本號碼寫入目前的目錄下的 .python-version 檔案的方式。通過這種方式設定的 Python 版本優先順序較 global 高。pyenv 會從目前的目錄開始向上逐級尋找 .python-version 檔案,直到根目錄為止。若找不到,就用 global 版本。
$ pyenv local2.7.3
pyenv shell
設定面向 shell 的 Python 版本,通過設定當前 shell 的 PYENV_VERSION 環境變數的方式。這個版本的優先順序比 local 和 global 都要高。--unset 參數可以用於取消當前 shell 設定的版本。
$ pyenv shell pypy-2.2.1$ pyenv shell--unset
[[email protected] ~]# pythonPython 2.7.5 (default, Jun 17 2014, 18:11:42) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> [[email protected] ~]# pyenv global 3.5.1[[email protected] ~]# pythonPython 3.5.1 (default, Jan 4 2016, 10:26:00) [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linuxType "help", "copyright", "credits" or "license" for more information.>>>
python多版本管理pyenv