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
- 创建之后的目录结构为
☁ .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
-
在PyCharm中为工程选择Project Interpreter
PyCharm->Perferences->Project->Project Interperter
在弹出窗口中,点左下角的+号,add local,然后输入路径mac pyenv virtualenv 2.7.11 3.5.2 多版本共存
-> 点击OK即为工程设置好相应环境的python解释器了。/Users/jerry/.pyenv/versions/3.5.1/envs/new-env-3.5.1/bin/python
mac pyenv virtualenv 2.7.11 3.5.2 多版本共存