天天看点

mac pyenv virtualenv 2.7.11 3.5.2 多版本共存

reference :https://github.com/yyuu/pyenv-installer       

1.首先安装pyenv 

        这里推荐bash安装方式,使用brew总会提示各种权限,link。

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

<!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->          配置mac环境变        # Load pyenv automatically by adding

       # the following to ~/.bash_profile:

       export PATH="/Users/admin/.pyenv/bin:$PATH"         eval "$(pyenv init -)        更新升级pyenv         pyenv update               pycharm指定python 版本            pyenv virtualenv 3.5.2 app 

  1. 创建之后的目录结构为
    ☁  .pyenv  pwd
    /Users/jerry/.pyenv
    ☁  .pyenv  tree -d -L 
    .
    ├── cache
    ├── plugins
    │   └── pyenv-virtualenv
    │       ├── bin
    │       ├── etc
    │       │   └── pyenv.d
    │       ├── shims
    │       └── test
    │           ├── stubs
    │           └── tmp
    ├── shims
    └── versions
        ├── 
        │   ├── bin
        │   ├── envs
        │   │   ├── my-virtualenv-
        │   │   └── new-env-
        │   ├── include
        │   │   └── python3m
        │   ├── lib
        │   │   ├── pkgconfig
        │   │   └── python3
        │   └── share
        │       └── man
        ├── my-virtualenv- -> /Users/jerry/.pyenv/versions//envs/my-virtualenv-
        └── new-env- -> /Users/jerry/.pyenv/versions//envs/new-env-
    
     directories
               
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
  2. 在PyCharm中为工程选择Project Interpreter

    PyCharm->Perferences->Project->Project Interperter

    mac pyenv virtualenv 2.7.11 3.5.2 多版本共存
    在弹出窗口中,点左下角的+号,add local,然后输入路径 

    /Users/jerry/.pyenv/versions/3.5.1/envs/new-env-3.5.1/bin/python

     -> 点击OK即为工程设置好相应环境的python解释器了。
    mac pyenv virtualenv 2.7.11 3.5.2 多版本共存