Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mitrofun/8673175681b765021af14e821be7ef0c to your computer and use it in GitHub Desktop.

Select an option

Save mitrofun/8673175681b765021af14e821be7ef0c 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment