Skip to content

Instantly share code, notes, and snippets.

@greggyNapalm
Last active November 7, 2015 15:09
Show Gist options
  • Save greggyNapalm/2003101 to your computer and use it in GitHub Desktop.
Save greggyNapalm/2003101 to your computer and use it in GitHub Desktop.
python dev env; mac os

basic Mac OS X cooking

# To uninstall @see http://guide.macports.org/chunked/installing.macports.uninstalling.html

useful dev tools

$ port -v selfupdate
$ port install coreutils findutils mc nmap curl wget mtr mercurial
$ port install vim +python27
$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /opt/local/bin/subl

python specific

$ port -v selfupdate
$ port install python27
$ port install py27-pip
$ port select --set python python27
$ ln -s /opt/local/bin/pip-2.7 /opt/local/bin/pip
$ pip install virtualenv virtualenvwrapper

# MySQL
$ port -v install py27-mysql
$ ln -s /opt/local/bin/mysql_config5 /opt/local/bin/mysql_config

# PostgreSQL
$ port install py27-psycopg2

Global ENV variables and bash_profile

# in ~/.bash_profile:

export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql91/bin:$PATH
export PATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH

#-------
# Python
#-------
WRAP_PATH=`which virtualenvwrapper.sh`
if [ $WRAP_PATH ]; then
    # We have wrapper script in PATH, let's use it.
    if [ ! -d ~/.virtualenvs ]; then
        mkdir ~/.virtualenvs
    fi
    export WORKON_HOME=~/.virtualenvs
    export VIRTUALENVWRAPPER_PYTHON=/opt/local/bin/python2.7
    export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
    #export PIP_VIRTUALENV_BASE=$WORKON_HOME
    export PIP_RESPECT_VIRTUALENV=true
    source $WRAP_PATH
fi

Get ipython and RDBMS drivers in new VENV

$ easy_install readline
$ pip install ipython
$ pip install MySQL-python
$ pip install psycopg2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment