2012-10-19 16:19:17 +00:00
|
|
|
======================
|
|
|
|
GeoDjango Installation
|
|
|
|
======================
|
|
|
|
|
|
|
|
.. highlight:: console
|
|
|
|
|
|
|
|
Overview
|
|
|
|
========
|
|
|
|
In general, GeoDjango installation requires:
|
|
|
|
|
2018-11-15 18:54:28 +00:00
|
|
|
#. :ref:`Python and Django <django>`
|
|
|
|
#. :ref:`spatial_database`
|
|
|
|
#. :doc:`geolibs`
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Details for each of the requirements and installation instructions
|
|
|
|
are provided in the sections below. In addition, platform-specific
|
|
|
|
instructions are available for:
|
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
* :ref:`macos`
|
2012-10-19 16:19:17 +00:00
|
|
|
* :ref:`windows`
|
|
|
|
|
|
|
|
.. admonition:: Use the Source
|
|
|
|
|
|
|
|
Because GeoDjango takes advantage of the latest in the open source geospatial
|
|
|
|
software technology, recent versions of the libraries are necessary.
|
|
|
|
If binary packages aren't available for your platform, installation from
|
|
|
|
source may be required. When compiling the libraries from source, please
|
|
|
|
follow the directions closely, especially if you're a beginner.
|
|
|
|
|
|
|
|
Requirements
|
|
|
|
============
|
|
|
|
|
|
|
|
.. _django:
|
|
|
|
|
|
|
|
Python and Django
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
Because GeoDjango is included with Django, please refer to Django's
|
|
|
|
:ref:`installation instructions <installing-official-release>` for details on
|
|
|
|
how to install.
|
|
|
|
|
|
|
|
.. _spatial_database:
|
|
|
|
|
|
|
|
Spatial database
|
|
|
|
----------------
|
2013-02-10 19:43:08 +00:00
|
|
|
PostgreSQL (with PostGIS), MySQL (mostly with MyISAM engine), Oracle, and SQLite
|
|
|
|
(with SpatiaLite) are the spatial databases currently supported.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
PostGIS is recommended, because it is the most mature and feature-rich
|
|
|
|
open source spatial database.
|
|
|
|
|
|
|
|
The geospatial libraries required for a GeoDjango installation depends
|
|
|
|
on the spatial database used. The following lists the library requirements,
|
|
|
|
supported versions, and any notes for each of the supported database backends:
|
|
|
|
|
|
|
|
================== ============================== ================== =========================================
|
|
|
|
Database Library Requirements Supported Versions Notes
|
|
|
|
================== ============================== ================== =========================================
|
2020-05-14 04:33:00 +00:00
|
|
|
PostgreSQL GEOS, GDAL, PROJ, PostGIS 9.6+ Requires PostGIS.
|
2020-05-19 08:56:39 +00:00
|
|
|
MySQL GEOS, GDAL 5.7+ :ref:`Limited functionality <mysql-spatial-limitations>`.
|
2019-02-06 18:25:04 +00:00
|
|
|
Oracle GEOS, GDAL 12.2+ XE not supported.
|
2020-05-10 20:30:03 +00:00
|
|
|
SQLite GEOS, GDAL, PROJ, SpatiaLite 3.8.3+ Requires SpatiaLite 4.3+
|
2012-10-19 16:19:17 +00:00
|
|
|
================== ============================== ================== =========================================
|
|
|
|
|
|
|
|
See also `this comparison matrix`__ on the OSGeo Wiki for
|
|
|
|
PostgreSQL/PostGIS/GEOS/GDAL possible combinations.
|
|
|
|
|
2015-11-29 16:29:46 +00:00
|
|
|
__ https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Installation
|
|
|
|
============
|
|
|
|
|
|
|
|
Geospatial libraries
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
.. toctree::
|
2016-02-19 07:31:25 +00:00
|
|
|
:maxdepth: 1
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2016-02-19 07:31:25 +00:00
|
|
|
geolibs
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Database installation
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
.. toctree::
|
2016-02-19 07:31:25 +00:00
|
|
|
:maxdepth: 1
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2016-02-19 07:31:25 +00:00
|
|
|
postgis
|
|
|
|
spatialite
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2018-01-31 17:09:26 +00:00
|
|
|
:setting:`DATABASES` configuration
|
|
|
|
----------------------------------
|
|
|
|
|
|
|
|
Set the :setting:`ENGINE <DATABASE-ENGINE>` setting to one of the :ref:`spatial
|
|
|
|
backends <spatial-backends>`.
|
|
|
|
|
2012-10-19 16:19:17 +00:00
|
|
|
Add ``django.contrib.gis`` to :setting:`INSTALLED_APPS`
|
|
|
|
-------------------------------------------------------
|
|
|
|
|
|
|
|
Like other Django contrib applications, you will *only* need to add
|
|
|
|
:mod:`django.contrib.gis` to :setting:`INSTALLED_APPS` in your settings.
|
2016-02-29 10:47:14 +00:00
|
|
|
This is so that the ``gis`` templates can be located -- if not done, then
|
2012-10-19 16:19:17 +00:00
|
|
|
features such as the geographic admin or KML sitemaps will not function properly.
|
|
|
|
|
|
|
|
Troubleshooting
|
|
|
|
===============
|
|
|
|
|
|
|
|
If you can't find the solution to your problem here then participate in the
|
|
|
|
community! You can:
|
|
|
|
|
2014-03-02 15:00:30 +00:00
|
|
|
* Join the ``#geodjango`` IRC channel on Freenode. Please be patient and polite
|
2012-10-19 16:19:17 +00:00
|
|
|
-- while you may not get an immediate response, someone will attempt to answer
|
|
|
|
your question as soon as they see it.
|
|
|
|
* Ask your question on the `GeoDjango`__ mailing list.
|
|
|
|
* File a ticket on the `Django trac`__ if you think there's a bug. Make
|
|
|
|
sure to provide a complete description of the problem, versions used,
|
|
|
|
and specify the component as "GIS".
|
|
|
|
|
2013-12-08 17:39:26 +00:00
|
|
|
__ https://groups.google.com/d/forum/geodjango
|
2012-10-19 16:19:17 +00:00
|
|
|
__ https://code.djangoproject.com/newticket
|
|
|
|
|
|
|
|
.. _libsettings:
|
|
|
|
|
|
|
|
Library environment settings
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
By far, the most common problem when installing GeoDjango is that the
|
|
|
|
external shared libraries (e.g., for GEOS and GDAL) cannot be located. [#]_
|
|
|
|
Typically, the cause of this problem is that the operating system isn't aware
|
|
|
|
of the directory where the libraries built from source were installed.
|
|
|
|
|
|
|
|
In general, the library path may be set on a per-user basis by setting
|
|
|
|
an environment variable, or by configuring the library path for the entire
|
|
|
|
system.
|
|
|
|
|
|
|
|
``LD_LIBRARY_PATH`` environment variable
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
A user may set this environment variable to customize the library paths
|
|
|
|
they want to use. The typical library directory for software
|
|
|
|
built from source is ``/usr/local/lib``. Thus, ``/usr/local/lib`` needs
|
|
|
|
to be included in the ``LD_LIBRARY_PATH`` variable. For example, the user
|
|
|
|
could place the following in their bash profile::
|
|
|
|
|
|
|
|
export LD_LIBRARY_PATH=/usr/local/lib
|
|
|
|
|
|
|
|
Setting system library path
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
On GNU/Linux systems, there is typically a file in ``/etc/ld.so.conf``, which may include
|
|
|
|
additional paths from files in another directory, such as ``/etc/ld.so.conf.d``.
|
|
|
|
As the root user, add the custom library path (like ``/usr/local/lib``) on a
|
|
|
|
new line in ``ld.so.conf``. This is *one* example of how to do so::
|
|
|
|
|
|
|
|
$ sudo echo /usr/local/lib >> /etc/ld.so.conf
|
|
|
|
$ sudo ldconfig
|
|
|
|
|
|
|
|
For OpenSolaris users, the system library path may be modified using the
|
|
|
|
``crle`` utility. Run ``crle`` with no options to see the current configuration
|
|
|
|
and use ``crle -l`` to set with the new library path. Be *very* careful when
|
|
|
|
modifying the system library path::
|
|
|
|
|
|
|
|
# crle -l $OLD_PATH:/usr/local/lib
|
|
|
|
|
|
|
|
.. _binutils:
|
|
|
|
|
|
|
|
Install ``binutils``
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
GeoDjango uses the ``find_library`` function (from the ``ctypes.util`` Python
|
|
|
|
module) to discover libraries. The ``find_library`` routine uses a program
|
|
|
|
called ``objdump`` (part of the ``binutils`` package) to verify a shared
|
|
|
|
library on GNU/Linux systems. Thus, if ``binutils`` is not installed on your
|
|
|
|
Linux system then Python's ctypes may not be able to find your library even if
|
|
|
|
your library path is set correctly and geospatial libraries were built perfectly.
|
|
|
|
|
|
|
|
The ``binutils`` package may be installed on Debian and Ubuntu systems using the
|
|
|
|
following command::
|
|
|
|
|
|
|
|
$ sudo apt-get install binutils
|
|
|
|
|
|
|
|
Similarly, on Red Hat and CentOS systems::
|
|
|
|
|
|
|
|
$ sudo yum install binutils
|
|
|
|
|
|
|
|
Platform-specific instructions
|
|
|
|
==============================
|
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
.. _macos:
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
macOS
|
|
|
|
-----
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
Because of the variety of packaging systems available for macOS, users have
|
2012-10-19 16:19:17 +00:00
|
|
|
several different options for installing GeoDjango. These options are:
|
|
|
|
|
2015-09-11 01:12:55 +00:00
|
|
|
* :ref:`postgresapp` (easiest and recommended)
|
2012-10-19 16:19:17 +00:00
|
|
|
* :ref:`homebrew`
|
|
|
|
* :ref:`kyngchaos`
|
|
|
|
* :ref:`fink`
|
|
|
|
* :ref:`macports`
|
|
|
|
* :ref:`build_from_source`
|
|
|
|
|
|
|
|
This section also includes instructions for installing an upgraded version
|
2017-04-23 20:06:12 +00:00
|
|
|
of :ref:`macos_python` from packages provided by the Python Software
|
2012-10-19 16:19:17 +00:00
|
|
|
Foundation, however, this is not required.
|
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
.. _macos_python:
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Python
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
Although macOS comes with Python installed, users can use `framework
|
2015-08-08 11:56:37 +00:00
|
|
|
installers`__ provided by the Python Software Foundation. An advantage to
|
2017-04-23 20:06:12 +00:00
|
|
|
using the installer is that macOS's Python will remain "pristine" for internal
|
2015-08-08 11:56:37 +00:00
|
|
|
operating system use.
|
|
|
|
|
|
|
|
__ https://www.python.org/ftp/python/
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
You will need to modify the ``PATH`` environment variable in your
|
|
|
|
``.profile`` file so that the new version of Python is used when
|
|
|
|
``python`` is entered at the command-line::
|
|
|
|
|
|
|
|
export PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
|
|
|
|
|
2015-09-11 01:12:55 +00:00
|
|
|
.. _postgresapp:
|
|
|
|
|
|
|
|
Postgres.app
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~~~
|
2015-09-11 01:12:55 +00:00
|
|
|
|
2018-01-07 13:28:41 +00:00
|
|
|
`Postgres.app <https://postgresapp.com/>`_ is a standalone PostgreSQL server
|
2015-09-11 01:12:55 +00:00
|
|
|
that includes the PostGIS extension. You will also need to install ``gdal`` and
|
|
|
|
``libgeoip`` with :ref:`homebrew`.
|
|
|
|
|
|
|
|
After installing Postgres.app, add the following to your ``.bash_profile`` so
|
|
|
|
you can run the package's programs from the command-line. Replace ``X.Y`` with
|
|
|
|
the version of PostgreSQL in the Postgres.app you installed:
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/X.Y/bin
|
|
|
|
|
|
|
|
You can check if the path is set up correctly by typing ``which psql`` at a
|
|
|
|
terminal prompt.
|
|
|
|
|
2012-10-19 16:19:17 +00:00
|
|
|
.. _homebrew:
|
|
|
|
|
|
|
|
Homebrew
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
`Homebrew`__ provides "recipes" for building binaries and packages from source.
|
|
|
|
It provides recipes for the GeoDjango prerequisites on Macintosh computers
|
2017-04-23 20:06:12 +00:00
|
|
|
running macOS. Because Homebrew still builds the software from source, `Xcode`_
|
|
|
|
is required.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Summary::
|
|
|
|
|
|
|
|
$ brew install postgresql
|
|
|
|
$ brew install postgis
|
|
|
|
$ brew install gdal
|
|
|
|
$ brew install libgeoip
|
|
|
|
|
2017-05-20 15:51:21 +00:00
|
|
|
__ https://brew.sh/
|
2017-04-23 20:06:12 +00:00
|
|
|
.. _Xcode: https://developer.apple.com/xcode/
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _kyngchaos:
|
|
|
|
|
|
|
|
KyngChaos packages
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
William Kyngesburye provides a number of `geospatial library binary packages`__
|
2019-06-17 14:54:55 +00:00
|
|
|
that help to get GeoDjango installed on macOS without compiling them from
|
|
|
|
source. However, `Xcode`_ is still necessary for compiling the Python database
|
|
|
|
adapters :ref:`psycopg2_kyngchaos` (for PostGIS).
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
SpatiaLite users should consult the :ref:`spatialite_macos` section
|
2012-10-19 16:19:17 +00:00
|
|
|
after installing the packages for additional instructions.
|
|
|
|
|
|
|
|
Download the framework packages for:
|
|
|
|
|
|
|
|
* UnixImageIO
|
|
|
|
* PROJ
|
|
|
|
* GEOS
|
|
|
|
* SQLite3 (includes the SpatiaLite library)
|
|
|
|
* GDAL
|
|
|
|
|
|
|
|
Install the packages in the order they are listed above, as the GDAL and SQLite
|
|
|
|
packages require the packages listed before them.
|
|
|
|
|
|
|
|
Afterwards, you can also install the KyngChaos binary packages for `PostgreSQL
|
|
|
|
and PostGIS`__.
|
|
|
|
|
|
|
|
After installing the binary packages, you'll want to add the following to
|
|
|
|
your ``.profile`` to be able to run the package programs from the command-line::
|
|
|
|
|
|
|
|
export PATH=/Library/Frameworks/UnixImageIO.framework/Programs:$PATH
|
|
|
|
export PATH=/Library/Frameworks/PROJ.framework/Programs:$PATH
|
|
|
|
export PATH=/Library/Frameworks/GEOS.framework/Programs:$PATH
|
|
|
|
export PATH=/Library/Frameworks/SQLite3.framework/Programs:$PATH
|
|
|
|
export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
|
|
|
|
export PATH=/usr/local/pgsql/bin:$PATH
|
|
|
|
|
2018-01-07 13:28:41 +00:00
|
|
|
__ https://www.kyngchaos.com/software/frameworks
|
|
|
|
__ https://www.kyngchaos.com/software/postgres
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _psycopg2_kyngchaos:
|
|
|
|
|
|
|
|
psycopg2
|
2016-01-03 10:56:22 +00:00
|
|
|
^^^^^^^^
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
After you've installed the KyngChaos binaries and modified your ``PATH``, as
|
|
|
|
described above, ``psycopg2`` may be installed using the following command::
|
|
|
|
|
2019-04-14 15:02:36 +00:00
|
|
|
$ python -m pip install psycopg2
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2013-01-29 15:45:40 +00:00
|
|
|
If you don't have ``pip``, follow the :ref:`installation instructions
|
2012-10-19 16:19:17 +00:00
|
|
|
<installing-official-release>` to install it.
|
|
|
|
|
|
|
|
.. _fink:
|
|
|
|
|
|
|
|
Fink
|
|
|
|
^^^^
|
|
|
|
|
|
|
|
`Kurt Schwehr`__ has been gracious enough to create GeoDjango packages for users
|
2014-11-13 13:34:47 +00:00
|
|
|
of the `Fink`__ package system. `Different packages are available`__ (starting
|
2016-11-15 22:00:50 +00:00
|
|
|
with ``django-gis``), depending on which version of Python you want to use.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2016-06-16 01:20:23 +00:00
|
|
|
__ https://schwehr.blogspot.com/
|
2012-10-19 16:19:17 +00:00
|
|
|
__ http://www.finkproject.org/
|
2014-11-13 13:34:47 +00:00
|
|
|
__ http://pdb.finkproject.org/pdb/browse.php?summary=django-gis
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _macports:
|
|
|
|
|
|
|
|
MacPorts
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
`MacPorts`__ may be used to install GeoDjango prerequisites on computers
|
|
|
|
running macOS. Because MacPorts still builds the software from source,
|
|
|
|
`Xcode`_ is required.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Summary::
|
|
|
|
|
2014-07-26 20:55:31 +00:00
|
|
|
$ sudo port install postgresql93-server
|
2012-10-19 16:19:17 +00:00
|
|
|
$ sudo port install geos
|
|
|
|
$ sudo port install proj
|
|
|
|
$ sudo port install postgis
|
|
|
|
$ sudo port install gdal +geos
|
|
|
|
$ sudo port install libgeoip
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
You will also have to modify the ``PATH`` in your ``.profile`` so
|
|
|
|
that the MacPorts programs are accessible from the command-line::
|
|
|
|
|
2014-07-26 20:55:31 +00:00
|
|
|
export PATH=/opt/local/bin:/opt/local/lib/postgresql93/bin
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
In addition, add the ``DYLD_FALLBACK_LIBRARY_PATH`` setting so that
|
|
|
|
the libraries can be found by Python::
|
|
|
|
|
2014-07-26 20:55:31 +00:00
|
|
|
export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib:/opt/local/lib/postgresql93
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2015-11-29 16:29:46 +00:00
|
|
|
__ https://www.macports.org/
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _windows:
|
|
|
|
|
|
|
|
Windows
|
|
|
|
-------
|
|
|
|
|
|
|
|
Proceed through the following sections sequentially in order to install
|
2020-06-10 20:00:15 +00:00
|
|
|
GeoDjango on Windows. In this tutorial we will install 64 bit versions of each
|
|
|
|
application.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Python
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
Install a 64 bit version of Python. See :doc:`Install Python </howto/windows>`
|
|
|
|
for further information.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
PostgreSQL
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
Download the latest `PostgreSQL 12.x installer`__ from the
|
2019-06-17 14:54:55 +00:00
|
|
|
`EnterpriseDB`__ website. After downloading, run the installer, follow the
|
|
|
|
on-screen directions, and keep the default options unless you know the
|
|
|
|
consequences of changing them.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
The PostgreSQL installer creates a new ``postgres`` database superuser
|
|
|
|
You will be prompted once to set the password -- make sure to remember it!
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
When the installer completes, it will ask to "Launch Stack Builder at exit?" --
|
|
|
|
keep this checked, as it is necessary to install :ref:`postgisasb`.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
If installed successfully, the PostgreSQL server will run in the background
|
|
|
|
each time the system as started as a Windows service. A
|
|
|
|
:menuselection:`PostgreSQL 12` start menu group will created and contains
|
|
|
|
shortcuts for the Application Stack Builder (ASB) as well as the
|
|
|
|
'SQL Shell', which will launch a ``psql`` command window.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2017-05-20 15:51:21 +00:00
|
|
|
__ https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
|
|
|
|
__ https://www.enterprisedb.com
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _postgisasb:
|
|
|
|
|
|
|
|
PostGIS
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
From within the Stack Builder (to run outside of the installer,
|
|
|
|
:menuselection:`Start --> PostgreSQL 12 --> Application Stack Builder`), select
|
|
|
|
:menuselection:`PostgreSQL 12 (x64) on port 5432` from the drop down
|
|
|
|
menu and click next. Expand the
|
|
|
|
:menuselection:`Categories --> Spatial Extensions` menu tree and select
|
|
|
|
:menuselection:`PostGIS X.Y for PostgreSQL 12`.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
After clicking next, you will be prompted to confirm the selected package and
|
|
|
|
"Download directory". Click next again, this will download PostGIS and you will
|
|
|
|
be asked to click next to begin the PostGIS installer. Select the default
|
|
|
|
options during install. The install process includes three Yes/No dialog boxes,
|
|
|
|
the default option for all three is "No".
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _osgeo4w:
|
|
|
|
|
|
|
|
OSGeo4W
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-05-10 20:30:03 +00:00
|
|
|
The `OSGeo4W installer`_ helps to install the PROJ, GDAL, and GEOS libraries
|
2020-06-10 20:00:15 +00:00
|
|
|
required by GeoDjango. First, download the `OSGeo4W installer`_ (64bit), and
|
|
|
|
run it. Select :menuselection:`Express Web-GIS Install` and click next. In the
|
|
|
|
'Select Packages' list, ensure that GDAL is selected; MapServer is also enabled
|
|
|
|
by default, but is not required by GeoDjango and may be unchecked safely. After
|
|
|
|
clicking next and accepting the license agreements, the packages will be
|
|
|
|
automatically downloaded and installed, after which you may exit the installer.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2015-11-29 16:29:46 +00:00
|
|
|
.. _OSGeo4W installer: https://trac.osgeo.org/osgeo4w/
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Modify Windows environment
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
In order to use GeoDjango, you will need to add your OSGeo4W
|
2012-10-19 16:19:17 +00:00
|
|
|
directories to your Windows system ``Path``, as well as create ``GDAL_DATA``
|
|
|
|
and ``PROJ_LIB`` environment variables. The following set of commands,
|
2020-06-10 20:00:15 +00:00
|
|
|
executable with ``cmd.exe``, will set this up. Restart your device
|
|
|
|
once this is complete for new environment variables to be recognized:
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. code-block:: bat
|
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
set OSGEO4W_ROOT=C:\OSGeo4W64
|
2016-02-19 07:31:25 +00:00
|
|
|
set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal
|
|
|
|
set PROJ_LIB=%OSGEO4W_ROOT%\share\proj
|
2020-06-10 20:00:15 +00:00
|
|
|
set PATH=%PATH%;%OSGEO4W_ROOT%\bin
|
2016-02-19 07:31:25 +00:00
|
|
|
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /f /d "%PATH%"
|
|
|
|
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v GDAL_DATA /t REG_EXPAND_SZ /f /d "%GDAL_DATA%"
|
|
|
|
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROJ_LIB /t REG_EXPAND_SZ /f /d "%PROJ_LIB%"
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
This assumes 64bit version of OSGeo4W is installed. If you have installed
|
|
|
|
the 32bit version you will need to change the first command to
|
|
|
|
``set OSGEO4W_ROOT=C:\OSGeo4W``.
|
|
|
|
|
2012-10-19 16:19:17 +00:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
Administrator privileges are required to execute these commands.
|
2020-06-10 20:00:15 +00:00
|
|
|
To do this, run command prompt as administrator and enter the commands
|
|
|
|
above. You need to log out and log back in again for the settings to take
|
|
|
|
effect.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
If you customized the OSGeo4W installation directories, then you will need
|
|
|
|
to modify the ``OSGEO4W_ROOT`` variables accordingly.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Install Django and set up database
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-06-10 20:00:15 +00:00
|
|
|
:ref:`install Django <installing-official-release>` on your system. It is
|
|
|
|
recommended that you create a :doc:`virtural environment
|
|
|
|
<python:tutorial/venv>` for each project you create.
|
|
|
|
|
|
|
|
psycopg2
|
|
|
|
~~~~~~~~
|
|
|
|
|
|
|
|
The ``psycopg2`` Python module provides the interface between Python and the
|
|
|
|
PostgreSQL database. ``psycopg2`` can be installed via pip within your Python
|
|
|
|
virtual environment::
|
|
|
|
|
2020-12-23 15:20:40 +00:00
|
|
|
...\> py -m pip install psycopg2
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. rubric:: Footnotes
|
|
|
|
.. [#] GeoDjango uses the :func:`~ctypes.util.find_library` routine from
|
2013-01-01 13:12:42 +00:00
|
|
|
``ctypes.util`` to locate shared libraries.
|