python 虚拟环境安装及使用 修改 使用

curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash

修改

vim /etc/profile

1
2
3
export PATH="/home/kongxx/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

source /etc/profile

使用

  1. 查看当前系统已安装并正在使用的 python 版本

    pyenv versions

    注:

    • system 是系统安装的包
    • * 表示当前正在使用的 python 环境
  2. 查看可以安装的 python 版本

    pyenv install -l

  3. 安装指定的 python 版本

    pyenv install 3.6.3

  4. 使用指定的 python 版本

    pyenv global 3.6.3

    验证:

    python -V

  5. 管理 virtualenv

    pyenv virtualenv 3.6.3 myenv

    激活 virtualenv:

    pyenv activate myenv

    停止 virtualenv:

    pyenv deactivate

    删除 virtualenv:

    pyenv virtualenv-delete myenv