-
Notifications
You must be signed in to change notification settings - Fork 1
Python Quick Start: OS X
Install Xcode from the App Store.
Homebrew is the preferred package manager for OS X. Uninstall MacPorts and uninstall Fink if you are using either, as they may conflict or cause issues with Homebrew. Then, install Homebrew if you haven't already.
Ensure Homebrew is up-to-date:
brew update
Ensure Homebrew issues no warnings and is ready to go. If you see a lot of warnings, you can usually proceed without correcting all of them:
brew doctor
Install Git:
brew install git
Install MongoDB and follow the post-installation instructions:
brew install mongodb
You can refer to the instructions at any time with:
brew info mongodb
Use Homebrew's Python, because using the Python that ships with OS X sometimes causes issues:
brew install python3
# `brew install python` for python 2.x
pip
is Python's package manager, used to install libraries, and was installed when Python was installed. If it was not installed, run:
easy_install pip
Install virtualenv and virtualenvwrapper, which are used to isolate Python project dependencies.
pip install virtualenv virtualenvwrapper
Make a directory to store your project-specific dependencies ("virtual environments"):
mkdir $HOME/.virtualenvs
Find out what UNIX shell you are using:
echo $SHELL
If you are using /bin/bash
, run the following to have virtualenvwrapper load when you start your shell:
echo "export WORKON_HOME=\$HOME/.virtualenvs" >> $HOME/.bashrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> $HOME/.bashrc
source $HOME/.bashrc
If you are using /bin/zsh
, run:
echo "export WORKON_HOME=\$HOME/.virtualenvs" >> $HOME/.zshrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> $HOME/.zshrc
source $HOME/.zshrc
You can now create and load a virtual environment:
mkvirtualenv name_of_your_project
Within a virtual environment, you can install libraries using pip
, and they will only be visible within that virtual environment:
pip install lxml
If you close your terminal or window and want to resume working within a virtual environment, run:
workon name_of_your_project
brew install gdal postgresql postgis
When installing gdal
, you may see a warning to install XQuartz.
Follow the PostgreSQL post-installation instructions:
brew info postgresql
Create a PostgreSQL database:
createdb database_name
Enable the PostGIS extension:
psql database_name -c "CREATE EXTENSION postgis;"
If you encounter the error Error: pg_config executable not found.
, the quick solution is to create a symlink to pg_config
.
Once you have Django installed, you should be able to run:
python -c "from django.contrib.gis.gdal import libgdal"
If you encounter an error containing:
Library not loaded: /usr/local/lib/libsqlite3.0.8.6.dylib
Or:
Library not loaded: /usr/local/lib/libproj.0.6.6.dylib
Check the Referenced from:
line and brew rm
and brew install
the mentioned package, e.g. gdal
for libgdal.dylib
, libspatialite
for libspatialite.dylib
, libgeotiff
for libgeotiff.2.dylib
, etc.