Are there any good step by step tutorials on setting up a Mac to use python, pip and virtualenv setup?
Download and install the Python 2.7.1 Mac OS X 64-bit/32-bit x86-64/i386 Installer (for Mac OS X 10.6) or Python 2.7.1 Mac OS X 32-bit i386/PPC Installer (for Mac OS X 10.3 through 10.6).
This is how I installed virtualenv
and pip
on 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
I also like to use virtualenvwrapper
with virtualenv
, so I installed it using:
sudo pip install virtualenvwrapper
I originally picked up this information from Jesse Noller's article "SO YOU WANT TO USE PYTHON ON THE MAC?"
~/.bash_profile
SettingsThis is probably overkill, but below is the Mac OS X section of my ~/.bash_profile
. I have multiple versions of Python installed using the Python.org installers, which is why I go through the for loop to add each version of 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
What problems?
easy-install pip
pip install virtualenv
virtualenv myenv
source myenv/bin/activate
or use myenv/bin/python
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With