Skip to content

Instantly share code, notes, and snippets.

@iraquitan
Created July 7, 2016 14:52
Show Gist options
  • Select an option

  • Save iraquitan/3120e0a4349c80000ff9dede8cafe5eb to your computer and use it in GitHub Desktop.

Select an option

Save iraquitan/3120e0a4349c80000ff9dede8cafe5eb to your computer and use it in GitHub Desktop.
PostgreSQL and psycopg2 initial setup on Mac with Homebrew and Python 3
# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# install postgresql
brew install postgresql
# start homebrew postgresql service
brew service start postgresql
# create a database with your username
createdb `whoami`
# test postgresql by running
psql -h localhost
# to exit psql prompt type
\q
# install python 3
brew install python3
# intall virtualenv
pip3 install virtualenv
# create virtualenv with python3 as base
virtualenv -p /usr/local/bin/python3 .virtualenvs/psql-env
# activate psql-env virtualenv
source .virtualenvs/psql-env/bin/activate
# update wheel, setuptools and pip
pip install --update pip
pip install --update wheel
pip install --update setuptools
# install psycopg2
pip install psycopg2
@flaugher

Copy link
Copy Markdown

There is a typo. Line 8 should say "services" not "service": brew services start postgresql.

It might also be helpful to mention that this command won't run in a Tmux console window.

@kornislaw

Copy link
Copy Markdown

Also in lines 32-34 this should be pip install --upgrade not --update.

@ChandraVijayDubey

Copy link
Copy Markdown

For line #8, if you get:

$ brew service start postgresql
Error: Unknown command: service

Try running: brew services start postgresql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment