---
title: "Pemasangan GeoDjango"
version: 2.0
locale: id
source: https://docs.djangoproject.com/id/2.0/ref/contrib/gis/install/
canonical: https://djangodocs.dev/id/2.0/ref/contrib/gis/install/
---
# Pemasangan GeoDjango

## Ikhtisar

Secara umum, pemasangan GeoDjango membutuhkan:

1. [Python dan Django](#django)
2. [Basisdata spasial](#spatial-database)
3. [Memasang pustaka Geospatial](/id/2.0/ref/contrib/gis/install/geolibs/)

Rincian untuk setiap dari persyaratan dan petunjuk pemasangan disediakan di bagian dibawah. Sebagai tambahan, petunjuk khusus-serambi tersedia untuk:

- [macOS](#macos)
- [Windows](/id/2.0/ref/contrib/gis/testing/#windows)

> **Gunakan Sumber**
>
> Karena GeoDjango mengambil keuntungan dari terkahir di teknologi perangkat lunak geospasial sumber terbuka, versi terakhir dari pustaka dibutuhkan. Jika paket biner tidak tersedia di serambi anda, pemasangan dari sumber mungkin dibutuhkan. Ketika menyusun pustaka dari sumber, harap ikuti petunjuk dengan teliti, khususnya jika anda adalah seorang pemula.

## Persyaratan

### Python dan Django

Because GeoDjango is included with Django, please refer to Django's
[installation instructions](/id/2.0/topics/install/#installing-official-release) for details on
how to install.

### Basisdata spasial

PostgreSQL (with PostGIS), MySQL (mostly with MyISAM engine), Oracle, and SQLite
(with SpatiaLite) are the spatial databases currently supported.

> **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:

| Basisdata | Persyaratan Pustaka | Versi Didukung | Catatan |
| --- | --- | --- | --- |
| PostgreSQL | GEOS, GDAL, PROJ.4, PostGIS | 9.3+ | Membutuhkan PostGIS. |
| MySQL | GEOS, GDAL | 5.5+ | Not OGC-compliant; [limited functionality](/id/2.0/ref/contrib/gis/db-api/#mysql-spatial-limitations). |
| Oracle | GEOS, GDAL | 12.1+ | XE tidak didukung. |
| SQLite | GEOS, GDAL, PROJ.4, SpatiaLite | 3.6.+ | Membutuhkan SpatiaLite 4.0+ |

Lihat juga  pada Wiki OSGeo untuk PostgreSQL/PostGIS/GEOS/GDAL kemungkinan perpaduan.

## Pemasangan

### Pustaka geospasial

- [Memasang pustaka Geospatial](/id/2.0/ref/contrib/gis/install/geolibs/)

### Pemasangan basisdata

- [Memasang PostGIS](/id/2.0/ref/contrib/gis/install/postgis/)
- [Memasang SpatiaLite](/id/2.0/ref/contrib/gis/install/spatialite/)

### [`DATABASES`](/id/2.0/ref/settings/#std-setting-DATABASES) configuration

Set the [`ENGINE`](/id/2.0/ref/settings/#std-setting-DATABASE-ENGINE) setting to one of the [spatial
backends](/id/2.0/ref/contrib/gis/db-api/#spatial-backends).

### Tambah `django.contrib.gis` ke [`INSTALLED_APPS`](/id/2.0/ref/settings/#std-setting-INSTALLED_APPS)

Like other Django contrib applications, you will *only* need to add
[`django.contrib.gis`](/id/2.0/ref/contrib/gis/#module-django.contrib.gis) to [`INSTALLED_APPS`](/id/2.0/ref/settings/#std-setting-INSTALLED_APPS) in your settings.
This is so that the `gis` templates can be located -- if not done, then
features such as the geographic admin or KML sitemaps will not function properly.

## Menyelesaikan masalah

Jika anda tidak dapat menemukan pemecahan padamasalah anda disini lalu ikut serta di komunitas! Anda dapat:

- Join the `#geodjango` IRC channel on Freenode. Please be patient and polite
  -- while you may not get an immediate response, someone will attempt to answer
  your question as soon as they see it.
- Tanyakan pertanyaan anda pada daftar penyuratan .
- Arsipkan sebuah tiket pada  jika anda beripikir ada kesalahan. Pastikan anda menyediakan gambaran lenglap dari masalah, versi yang digunakan, dan tentukan komponen sebagai "GIS".

### Pustaka pengaturan lingkungan

By far, the most common problem when installing GeoDjango is that the
external shared libraries (e.g., for GEOS and GDAL) cannot be located. [^1]
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.

#### Variabel lingkungan `LD_LIBRARY_PATH`

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:

```console
export LD_LIBRARY_PATH=/usr/local/lib
```

#### Menyetel jalur pustakan sistem

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:

```console
$ 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:

```console
# crle -l $OLD_PATH:/usr/local/lib
```

#### Pasang `binutils`

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:

```console
$ sudo apt-get install binutils
```

Mirip, pada sistem Red Hat dan CentOS:

```console
$ sudo yum install binutils
```

## Petunjuk khusus-serambi

### macOS

Because of the variety of packaging systems available for macOS, users have
several different options for installing GeoDjango. These options are:

- [Postgres.app](#postgresapp) (paling mudah dan dianjurkan)
- [Homebrew](/id/2.0/ref/contrib/gis/install/spatialite/#homebrew)
- [KyngChaos](/id/2.0/ref/contrib/gis/install/spatialite/#kyngchaos)
- [Fink](#fink)
- [MacPorts](#macports)
- [Membangun dari sumber](/id/2.0/ref/contrib/gis/install/geolibs/#build-from-source)

This section also includes instructions for installing an upgraded version
of [Python](#macos-python) from packages provided by the Python Software
Foundation, however, this is not required.

#### Python

Although macOS comes with Python installed, users can use  provided by the Python Software Foundation.  An advantage to
using the installer is that macOS's Python will remain "pristine" for internal
operating system use.

> **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:
>
> ```console
> export PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
> ```

#### Postgres.app

[Postgres.app](https://postgresapp.com/) is a standalone PostgreSQL server
that includes the PostGIS extension. You will also need to install `gdal` and
`libgeoip` with [Homebrew](/id/2.0/ref/contrib/gis/install/spatialite/#homebrew).

Setelah memasang Postgres.app, tambah berikut ke `.bash_profile` anda sehingga anda dapat menjalankan progam paket dari baris-perintah. Ganti `X.Y` dengan versi PostgreSQL di Postgres.app anda pasang:

```bash
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/X.Y/bin
```

Anda dapat memeriksa jalur disetel dengan benar dengan mengetik `which psql` pada terminal prompt.

#### Homebrew

 provides "recipes" for building binaries and packages from source.
It provides recipes for the GeoDjango prerequisites on Macintosh computers
running macOS. Because Homebrew still builds the software from source, [Xcode](https://developer.apple.com/xcode/)
is required.

Ringkasan:

```console
$ brew install postgresql
$ brew install postgis
$ brew install gdal
$ brew install libgeoip
```

#### Paket KyngChaos

William Kyngesburye provides a number of
that make it simple to get GeoDjango installed on macOS without compiling
them from source.  However, [Xcode](https://developer.apple.com/xcode/) is still necessary for compiling the
Python database adapters [psycopg2](#psycopg2-kyngchaos) (for PostGIS).

> **Note**
>
> SpatiaLite users should consult the [Petunjuk-petunjuk khusus-macOS](/id/2.0/ref/contrib/gis/install/spatialite/#spatialite-macos) section
> after installing the packages for additional instructions.

Unduh paket kerangka untuk:

- UnixImageIO
- PROJ
- GEOS
- SQLite3 (menyertakan pustaka SpatiaLite)
- GDAL

Memasang paket-paket di urutan mereka terdaftar diatas, seperti paket GDAL dan SQLite membutuhkan paket-paket terdaftar sebelum mereka.

Setelah itu, anda dapat juga memasang paket biner KyngChaos untuk 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:

```console
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
```

##### psycopg2

After you've installed the KyngChaos binaries and modified your `PATH`, as
described above, `psycopg2` may be installed using the following command:

```console
$ pip install psycopg2
```

> **Note**
>
> If you don't have `pip`, follow the [installation instructions](/id/2.0/topics/install/#installing-official-release) to install it.

##### Fink

 has been gracious enough to create GeoDjango packages for users
of the  package system.  (starting
with `django-gis`), depending on which version of Python you want to use.

#### MacPorts

 may be used to install GeoDjango prerequisites on computers
running macOS.  Because MacPorts still builds the software from source,
[Xcode](https://developer.apple.com/xcode/) is required.

Ringkasan:

```console
$ sudo port install postgresql93-server
$ 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:
>
> ```console
> export PATH=/opt/local/bin:/opt/local/lib/postgresql93/bin
> ```
>
> In addition, add the `DYLD_FALLBACK_LIBRARY_PATH` setting so that
> the libraries can be found by Python:
>
> ```console
> export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib:/opt/local/lib/postgresql93
> ```

### Windows

Proceed through the following sections sequentially in order to install
GeoDjango on Windows.

#### Python

[Install Python](/id/2.0/howto/windows/).

#### PostgreSQL

Pertama, unduh  terakhir dari situs jaringan . Setelah mengunduh, cukup jalankan pemasang, ikuti arahan layar, dan jaga pilihan awal kecuali kalau anda mengetahui konsekuensi merubah mereka.

> **Note**
>
> Pemasang PostgreSQL membuat kedua pengguna Windows baru menjadi 'postgres service account' dan superuser basisdata `postgres`. Anda akan diarahkan sekali untuk menyetel sandi untuk kedua akun -- pastikan untuk mengingatnya!

Ketika pemasang lengkap, dia akan menanyakan untuk meluncurkan Application Stack Builder (ASB) pada keluar -- jaga ini tercentang, seperti dia diperlukan untuk memasang install [PostGIS](#postgisasb).

> **Note**
>
> Jika berhasil terpasang, peladen PostgreSQL akan berjalan dalam latar belakang setiap kali sistem dimulai sebagai layanan Window. Sebuah kelompok menu mulai PostgreSQL 9.x akan dibuat dan mengandung jalan pintas untuk ASB dan juga 'SQL Shell', yang akan meluncurkan jendela perintah `psql`.

#### PostGIS

From within the Application Stack Builder (to run outside of the installer,
Start ‣ Programs ‣ PostgreSQL 9.x), select
PostgreSQL Database Server 9.x on port 5432 from the drop down
menu.  Next, expand the Categories ‣ Spatial Extensions menu
tree and select PostGIS X.Y for PostgreSQL 9.x.

After clicking next, you will be prompted to select your mirror, PostGIS
will be downloaded, and the PostGIS installer will begin.  Select only the
default options during install (e.g., do not uncheck the option to create a
default PostGIS database).

> **Note**
>
> You will be prompted to enter your `postgres` database superuser
> password in the 'Database Connection Information' dialog.

#### psycopg2

The `psycopg2` Python module provides the interface between Python and the
PostgreSQL database.  Download the latest  for your version
of Python and PostgreSQL and run using the default settings. [^2]

#### OSGeo4W

The [OSGeo4W installer](https://trac.osgeo.org/osgeo4w/) makes it simple to install the PROJ.4, GDAL, and GEOS
libraries required by GeoDjango.  First, download the [OSGeo4W installer](https://trac.osgeo.org/osgeo4w/),
and run it.  Select Express Web-GIS Install and click next.
In the 'Select Packages' list, ensure that GDAL is selected; MapServer and
Apache are also enabled by default, but are not required by GeoDjango and
may be unchecked safely.  After clicking next, the packages will be
automatically downloaded and installed, after which you may exit the
installer.

#### Merubah lingkungan Windows

In order to use GeoDjango, you will need to add your Python and OSGeo4W
directories to your Windows system `Path`, as well as create `GDAL_DATA`
and `PROJ_LIB` environment variables.  The following set of commands,
executable with `cmd.exe`, will set this up:

```bat
set OSGEO4W_ROOT=C:\OSGeo4W
set PYTHON_ROOT=C:\Python3X
set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal
set PROJ_LIB=%OSGEO4W_ROOT%\share\proj
set PATH=%PATH%;%PYTHON_ROOT%;%OSGEO4W_ROOT%\bin
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%"
```

> **Note**
>
> Administrator privileges are required to execute these commands.
> To do this, create a `bat` script with the commands, right-click it, and
> select Run as administrator. You need to log out and log
> back in again for the settings to take effect.

> **Note**
>
> If you customized the Python or OSGeo4W installation directories,
> then you will need to modify the `OSGEO4W_ROOT` and/or `PYTHON_ROOT`
> variables accordingly.

#### Pasang Django dan setel basisdata

Akhirnya, [pasang Django](/id/2.0/topics/install/#installing-official-release) di sistem anda.

**Catatan kaki**

[^1]: GeoDjango menggunakan rutin [`find_library()`](https://docs.python.org/3/library/ctypes.html#ctypes.util.find_library) dari `ctypes.util` untuk menempatkan pustaka dibagi.

[^2]: Pemasang Windows\`\`psycopg2\`\` dipanketkan dan dirawat oleh [Jason Erickson](http://www.stickpeople.com/projects/python/win-psycopg/).
