Skip to content

Instantly share code, notes, and snippets.

@kaydell
Last active December 24, 2015 16:09
Show Gist options
  • Save kaydell/6826385 to your computer and use it in GitHub Desktop.
Save kaydell/6826385 to your computer and use it in GitHub Desktop.
Configure Python 3 Without Losing Python 2 On Mac OS X
# This code needs to be placed within the .bash_profile file of the user's home directory
# You can use a text editor such as Text Wrangler.app downloaded from the following
# link to create or edit the file .bash_profile, which is an invisible file because it begins
# with a dot.
# TextWrangler: http://www.barebones.com/products/textwrangler/download.html
# set the path to our Python Library
# require that '$HOME' be set to a dir
if [ -d "$HOME" ]; then
# set the path to our PYTHON_LIB
PYTHON_LIB="${HOME}/Sites/public_html/lib/python" ###### set PYTHON_LIB to your Python 3
# if '$PYTHONPATH' is set, then add our PYTHON_LIB to PYTHONPATH
if [[ "$PYTHONPATH" ]]; then
export PYTHONPATH="${PYTHONPATH}:${PYTHON_LIB}"
# else, PYTHONPATH isn't set so just set it to our PYTHON_LIB
else
export PYTHONPATH="${PYTHON_LIB}"
fi
# make PYTHONPATH available outside of this script
export PYTHONPATH
else
# write to stderr because there was an error
echo ".bash_profile: \$HOME \"$HOME\" is not a directory, so the path PYTHON_LIB could not be set: " >&2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment