Mac上python环境配置

Life is short, I use pythonpython

pyenv用来管理多个版本的python在用户目录的安装和使用, 相似rbenvgit

pyenv与pyenv-virtualenvwrapper:

brew install python pyenv pyenv-virtualenvwrapper

sudo pip install virtualenvwrapper

#若是pip不存在
sudo easy_install pip

>而后你须要把如下内容粘贴到~/.bash_profile文件中
# pyenv
PYENV_ROOT="$HOME/.pyenv"
PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

#pyenv virtualenvwrapper
pyenv virtualenvwrapper_lazy

安装python

//由于MAC El Capitan安装python3.5.0时找不到zlib,因此加上CFLAGS和LDFLAGS
CFLAGS="-I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
pyenv install 3.5.0

pyenv rehash

设置使用python版本

//这里不推荐使用系统默认版本(即system), 默认版本在用virtualenvwrapper会报错
pyenv global 3.5.0

pyenv与homebrew冲突解决

#添加到上述文件中
#pyenv not playing nice with homebrew
alias brew="env PATH=${PATH//$(pyenv root)\/shims:/} brew"

pyenv基本用法

1.安装pythongithub

pyenv install 2.7.10
pyenv rehash

2.删除pythonsegmentfault

pyenv uninstall 2.7.10

3.查看已安装版本api

pyenv versions

4.查看当前使用版本bash

pyenv version

virtualenvwrapper基本用法

以前记得从新启动下Terminal, 使上面配置生效app

1.建立一个(虚拟?)开发环境code

mkvirtualenv testing

workon testing

2.装一些听都没听过的依赖包(前面的括号里面会显示你如今用哪个环境的)homebrew

pip install ... (例如: cherrypy, routes)

3.用的不爽删了就是了ip

deactivate (或者切换到其余python虚拟环境中)

rmvirtualenv testing
相关文章
相关标签/搜索