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 多版本共存