$ 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 Speed
100 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 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
Python 2.7.5 (default, Jun 17 2014, 18:11:42)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Python 3.5.1 (default, Jan 4 2016, 10:26:00)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>