Setting up a complete GeoDjango development environment on OS X

31.03.2014: homebrew progressed quite a lot and it’s much easier now to setup a complete  GeoDjango environment like this:

ruby -e “$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)”

brew install python
brew install postgis15
(OR: brew install homebrew/versions/postgis15)

Run this command to autorun PostgreSQL when OS X fires up:
cp /usr/local/Cellar/postgresql9/9.0.17/homebrew.mxcl.postgresql9.plist ~/Library/LaunchAgents/

brew install graphicsmagick
brew install gs
brew link gs
brew install git
brew install mercurial
brew install autoenv

brew install nodejs
npm install -g less
npm install -g typescript

pip install virtualenv
sudo pip install virtualenvwrapper

~/.bash_profile only contains these three lines:
export PATH=/usr/local/bin:$PATH
export WORKON_HOME=~/PythonEnvs
source /usr/local/bin/virtualenvwrapper.sh

mkvirtualenv -p /usr/local/bin/python django15
workon django15
pip install django-cms

initdb /usr/local/var/postgres

createdb -E UTF8 template_postgis
createlang -d template_postgis plpgsql

psql -d postgres -c “UPDATE pg_database SET datistemplate=’true’ WHERE datname=’template_postgis’;”

psql -d template_postgis -f /usr/local/Cellar/postgis15/1.5.8/share/postgis/postgis.sql

psql -d template_postgis -f /usr/local/Cellar/postgis15/1.5.8/share/postgis/spatial_ref_sys.sql

Enabling users to alter spatial tables:

psql -d template_postgis -c “GRANT ALL ON geometry_columns TO PUBLIC;”
psql -d template_postgis -c “GRANT ALL ON spatial_ref_sys TO PUBLIC;”

createdb -T template_postgis PROJECT


UPGRADES & UPDATES:

brew doctor
brew update
brew upgrade
pip install –upgrade pip
pip install –upgrade -r requirements.txt


USER INSTALLED VS. OS X DEFAULTS:

User installed:

/Applications/Python 2.7/
/Library/Frameworks/Python.framework
/Library/Frameworks/Python.framework/Versions/Current/bin/python
/usr/local/bin/python

/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework
/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/Current/bin/python

OS X installed by default:

/Library/Python
/Library/Python/2.3
/Library/Python/2.5
/Library/Python/2.6
/Library/Python/2.7
/System/Library/Frameworks/Python.framework
/System/Library/Frameworks/Python.framework/Python
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/python.o
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/idlelib/Icons/python.gif
/System/Library/Frameworks/Python.framework/Versions/2.3/Python
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python-config
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-config
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw
/System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyObjC/objc/_pythonify.py
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyObjC/objc/_pythonify.pyc
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/python_dateutil-1.5-py2.5.egg-info
/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python-ast.h
/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h
/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pythonrun.h
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config/libpython2.5.a
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config/libpython2.5.dylib
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config/python.o
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ctypes/test/test_python_api.py
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ctypes/test/test_python_api.pyc
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ctypes/test/test_python_api.pyo
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/idlelib/Icons/python.gif
/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload/Python-2.5.6-py2.5.egg-info
/System/Library/Frameworks/Python.framework/Versions/2.5/Python
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/Resources/English.lproj/Documentation/python.gif
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/Resources/English.lproj/Documentation/pythonsmall.gif
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/Resources/PythonApplet.icns
/System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/Resources/PythonInterpreter.icns
/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python
/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python-config
/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
/System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw
/System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/matplotlib/sphinxext/ipython_console_highlighting.py
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/matplotlib/sphinxext/ipython_console_highlighting.pyc
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/_pythonify.py
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC/objc/_pythonify.pyc
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/python_dateutil-1.5-py2.6.egg-info
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted/python
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted/trial/test/notpython
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python-ast.h
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pythonrun.h
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config/libpython2.6.a
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config/libpython2.6.dylib
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config/python.o
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/test/test_python_api.py
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/test/test_python_api.pyc
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ctypes/test/test_python_api.pyo
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/idlelib/Icons/python.gif
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/Python-2.6.8-py2.6.egg-info
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/test/https_svn_python_org_root.pem
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/test/svn_python_org_https_cert.pem
/System/Library/Frameworks/Python.framework/Versions/2.6/Python
/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app
/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/Resources/English.lproj/Documentation/python.gif
/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/Resources/English.lproj/Documentation/pythonsmall.gif
/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/Resources/PythonApplet.icns
/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/Resources/PythonInterpreter.icns
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/sphinxext/ipython_console_highlighting.py
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/sphinxext/ipython_console_highlighting.pyc
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_pythonify.py
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/objc/_pythonify.pyc
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/python_dateutil-1.5-py2.7.egg-info
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/twisted/trial/test/notpython
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python-ast.h
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h
/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pythonrun.h
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig/python-2.7.pc
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig/python.pc
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/pkgconfig/python2.pc
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.a
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/python.o
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/test/test_python_api.py
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/test/test_python_api.pyc
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/test/test_python_api.pyo
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/idlelib/Icons/python.gif
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/Python-2.7.5-py2.7.egg-info
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/test/https_svn_python_org_root.pem
/System/Library/Frameworks/Python.framework/Versions/2.7/Python
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/BridgeSupport/Python.bridgesupport
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/Resources/PythonApplet.icns
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/Resources/PythonInterpreter.icns
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/Inline/Python
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/Inline/Python/Python.bs
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/Inline/Python/Python.bundle
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/Inline/Python.pm
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/Inline/Python.pod
/System/Library/Perl/Extras/5.16/darwin-thread-multi-2level/auto/Inline/Python
/System/Library/Perl/Extras/5.16/darwin-thread-multi-2level/auto/Inline/Python/Python.bs
/System/Library/Perl/Extras/5.16/darwin-thread-multi-2level/auto/Inline/Python/Python.bundle
/System/Library/Perl/Extras/5.16/darwin-thread-multi-2level/Inline/Python.pm
/System/Library/Perl/Extras/5.16/darwin-thread-multi-2level/Inline/Python.pod
/usr/bin/python
/usr/bin/python-config
/usr/bin/python2.5
/usr/bin/python2.5-config
/usr/bin/python2.6
/usr/bin/python2.6-config
/usr/bin/python2.7
/usr/bin/python2.7-config
/usr/bin/pythonw
/usr/bin/pythonw2.5
/usr/bin/pythonw2.6
/usr/bin/pythonw2.7
/usr/lib/libpython.dylib
/usr/lib/libpython2.5.dylib
/usr/lib/libpython2.6.dylib
/usr/lib/libpython2.7.dylib
/usr/lib/python2.5
/usr/lib/python2.6
/usr/lib/python2.7
/usr/share/emacs/22.1/lisp/progmodes/python.el.gz
/usr/share/emacs/22.1/lisp/progmodes/python.elc
/usr/share/file/magic/python
/usr/share/man/man1/python.1
/usr/share/man/man1/python2.5.1
/usr/share/man/man1/python2.6.1
/usr/share/man/man1/python2.7.1
/usr/share/man/man1/pythonw.1
/usr/share/man/man1/pythonw2.5.1
/usr/share/man/man1/pythonw2.6.1
/usr/share/man/man1/pythonw2.7.1
/usr/share/vim/vim73/autoload/python3complete.vim
/usr/share/vim/vim73/autoload/pythoncomplete.vim
/usr/share/vim/vim73/ftplugin/python.vim
/usr/share/vim/vim73/indent/python.vim
/usr/share/vim/vim73/syntax/python.vim
/usr/share/zsh/5.0.2/functions/_python


UNINSTALL:

1. uninstall homebrew: http://superuser.com/questions/203707/how-to-uninstall-homebrew-osx-package-manager

2. uninstall pip:
rm -rf /usr/local/lib/python2.7
rm -f /usr/local/bin/pip
rm -f /usr/local/bin/pip-2.6
rm -f /usr/local/bin/pip-2.7
rm -f /usr/local/bin/hg


TACKLING PROBLEMS:

Error running xgettext. Note that Django internationalization requires GNU gettext 0.15 or newer.

ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/autopoint /usr/local/bin/autopoint
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/envsubst /usr/local/bin/envsubst
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/gettext /usr/local/bin/gettext
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/gettext.sh /usr/local/bin/gettext.sh
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/gettextize /usr/local/bin/gettextize
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgattrib /usr/local/bin/msgattrib
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgcat /usr/local/bin/msgcat
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgcmp /usr/local/bin/msgcmp
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgcomm /usr/local/bin/msgcomm
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgconv /usr/local/bin/msgconv
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgen /usr/local/bin/msgen
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgexec /usr/local/bin/msgexec
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgfilter /usr/local/bin/msgfilter
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgfmt /usr/local/bin/msgfmt
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msggrep /usr/local/bin/msggrep
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msginit /usr/local/bin/msginit
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgmerge /usr/local/bin/msgmerge
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msgunfmt /usr/local/bin/msgunfmt
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/msguniq /usr/local/bin/msguniq
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/ngettext /usr/local/bin/ngettext
ln -s /usr/local/Cellar/gettext/0.18.3.2/bin/xgettext /usr/local/bin/xgettext

Error: [Errno 8] nodename nor servname provided, or not known: http://stackoverflow.com/questions/12102236/wsgiserverexception-errno-8-nodename-nor-servname-provided-or-not-known/23471411#23471411

DatabaseError: could not access file “$libdir/postgis-1.5”: No such file or directory
The file /usr/local/Cellar/postgresql9/9.0.17/lib/postgis-1.5.so is missing. This error happened after brew upgrade and the solution is to uninstall postgis and reinstall it with:

brew uninstall postgis15
brew install postgis15

The result should be: PostGIS plugin libraries installed to: /usr/local/Cellar/postgresql9/9.0.17/lib

So afterwards you should find the file /usr/local/Cellar/postgresql9/9.0.17/lib/postgis-1.5.so


Set it up like we did in the past:

http://blog.philippmetzler.com/django-install-osx/topics/install-osx.html

Leave a Reply

Your email address will not be published. Required fields are marked *

For spam filtering purposes, please copy the number 8490 to the field below: