下载并安装Python 2.7.1 Mac OS X 64位/ 32位x86-64/i386安装程序(适用于Mac OS X 10.6)或Python 2.7.1 Mac OS X 32位i386/PPC安装程序(适用于Mac OS) X 10.3至10.6).
这是我如何安装virtualenv和pip在OS X:
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
sudo easy_install pip
sudo pip install virtualenv
Run Code Online (Sandbox Code Playgroud)
我也喜欢virtualenvwrapper用virtualenv,所以我用它安装:
sudo pip install virtualenvwrapper
Run Code Online (Sandbox Code Playgroud)
我最初从Jesse Noller的文章"你想要在MAC上使用 PYTH ?"中获取这些信息.
~/.bash_profile 设置这可能是矫枉过正,但下面是我的Mac OS X部分~/.bash_profile.我使用Python.org安装程序安装了多个版本的Python,这就是我通过for循环添加每个版本的Python的原因.
# Mac OS X specific settings
if [ ${os_name} == 'Darwin' ]; then
# The last Python added to PATH will be the default Python
PY_VER=( '3.1' '2.6' '2.7')
PY_VER_ELEMENTS=${#PY_VER[@]}
DEFAULT_PY=${PY_VER[${PY_VER_ELEMENTS}-1]}
PY_FW="/Library/Frameworks/Python.framework/Versions"
for (( i=0;i<$PY_VER_ELEMENTS;i++)); do
if [ -x ${PY_FW}/${PY_VER[${i}]}/bin/python${PY_VER[${i}]} ]; then
PATH="${PY_FW}/${PY_VER[${i}]}/bin:${PATH}"
export PATH
fi
done
# Check for virtualenv in the default Python
if [ -x ${PY_FW}/${DEFAULT_PY}/bin/virtualenv ]; then
export VIRTUALENV_USE_DISTRIBUTE=true
export WORKON_HOME=$HOME/.virtualenvs
fi
# Check for pip
if [ -x ${PY_FW}/${DEFAULT_PY}/bin/pip ]; then
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_REQUIRE_VIRTUALENV=true
export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache
fi
# Enable virtualenvwrapper
if [ -x ${PY_FW}/${DEFAULT_PY}/bin/virtualenvwrapper.sh ]; then
source ${PY_FW}/${DEFAULT_PY}/bin/virtualenvwrapper.sh
fi
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3389 次 |
| 最近记录: |