Created
July 7, 2016 14:52
-
-
Save iraquitan/3120e0a4349c80000ff9dede8cafe5eb to your computer and use it in GitHub Desktop.
PostgreSQL and psycopg2 initial setup on Mac with Homebrew and Python 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
Also in lines 32-34 this should be pip install --upgrade not --update.
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
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.