---
title: "Pemasangan GeoDjango"
version: 5.2
locale: id
source: https://docs.djangoproject.com/id/5.2/ref/contrib/gis/install/
canonical: https://djangodocs.dev/id/5.2/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/5.2/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](#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

Karena GeoDjango disertakan dengan Django, harap mengacu pada [installation instructions](/id/5.2/topics/install/#installing-official-release)  Django untuk rincian bagaimana memasang.

### Basisdata spasial

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

> **Note**
>
> PostGIS dianjurkan, karena itu adalah paling matang dan basisdata spasial sumber terbuka kaya-fitur.

Pustaka-pustaka gespasial dibutuhkan untuk pemasangan GeoDjango tergantung pada basisdata spasial digunakan. Daftar berikut persyaratan pustaka, versi didukung, dan catatan apapun untuk setiap dari backend basisdata didukung:

| Basisdata | Persyaratan Pustaka | Versi Didukung | Catatan |
| --- | --- | --- | --- |
| PostgreSQL | GEOS, GDAL, PROJ, PostGIS | 14+ | Membutuhkan PostGIS. |
| MySQL | GEOS, GDAL | 8.0.11+ | [Limited functionality](/id/5.2/ref/contrib/gis/db-api/#mysql-spatial-limitations). |
| Oracle | GEOS, GDAL | 19+ | XE tidak didukung. |
| SQLite | GEOS, GDAL, PROJ, SpatiaLite | 3.31.0+ | Membutuhkan SpatiaLite 4.3+ |

Lihat juga [this comparison matrix](https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS) pada Wiki OSGeo untuk PostgreSQL/PostGIS/GEOS/GDAL kemungkinan perpaduan.

## Pemasangan

### Pustaka geospasial

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

### Pemasangan basisdata

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

### Konfigurasi [`DATABASES`](/id/5.2/ref/settings/#std-setting-DATABASES)

Setel pengaturan [`ENGINE`](/id/5.2/ref/settings/#std-setting-DATABASE-ENGINE) menjadi satu dari the [spatial backends](/id/5.2/ref/contrib/gis/db-api/#spatial-backends).

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

Seperti aplikasi bantuan Django lain, anda akan *hanya* butuh menambahkan [`django.contrib.gis`](/id/5.2/ref/contrib/gis/#module-django.contrib.gis) ke [`INSTALLED_APPS`](/id/5.2/ref/settings/#std-setting-INSTALLED_APPS) dalam pengaturan anda. Ini sehingga cetakan `gis` dapat ditempatkan -- jika belum selesai, kemudian fitur-fitur seperti admin georgafis atau peta situs KML tidak akan berfungsi dengan baik.

## Menyelesaikan masalah

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

- Tanya pertanyaan anda di forum [GeoDjango](https://forum.djangoproject.com/c/internals/geodjango/13).
- Arsipkan sebuah tiket pada [Django trac](https://code.djangoproject.com/newticket) jika anda beripikir ada kesalahan. Pastikan anda menyediakan gambaran lenglap dari masalah, versi yang digunakan, dan tentukan komponen sebagai "GIS".

### Pustaka pengaturan lingkungan

Sejauh ini, masalah paling umum ketika memasang GeoDjango adalah bahwa pustaka-pustaka berbagi eksternal (misalnya, untuk GEOS dan GDAL) tidak dapat ditempatkan. [^1] Khususnya, penyebab masalah ini adalah bahwa sistem operasi tidak waspada dari direktori dimana pustaka-pustaka dibangun dari sumber yang dipasang.

Secara umum, jalur pustaka mungkin disetel pada dasar per-pengguna dengan mengatur varibel lingkungan, atau dengan mengkonfigurasi jalur pustaka untuk sistem kesulurhan.

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

```shell
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:

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

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

#### Pasang `binutils`

GeoDjango menggunakan fungsi `find_library` (dari modul Python `ctypes.util`) untuk menemukan pustaka. Rutin `find_library` menggunakan sebuah program disebut `objump` (bagian dari paket `binutils`) untuk memeriksa pustaka berbagi pada sistem GNU/Linux. Dengan demikian, jika `binutils` tidak dipasang pada sistem Linux anda kemudian ctypes Python mungkin tidak dapat menemukan pustaka anda bahkan jika jalur pustaka anda disetel dengan benar dan pustaka-pustaka geospasial dibangun dengan sempurna.

The `binutils` package may be installed on Debian and Ubuntu systems using the
following command:

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

Demikian pula, pada sistem Red Hat dan CentOS:

```shell
$ sudo yum install binutils
```

## Petunjuk khusus-serambi

### macOS

Karena beragam dari sistem pemaketan tersedia untuk macOS, pengguna mempunyai beberapa pilihan berbeda untuk memasang GeoDjango. Pilihan ini adalah:

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

Bagian ini juga menyertakan petunjuk untuk pemasangan sebuah versi tertingkatkan dari [Python](#macos-python) dari paket-paket disediakan oleh Python Software Foundation, bagaimanapun, ini tidak diwajibkan.

#### Python

Meskipun macOS datang dengan Python terpasang, pengguna dapat menggunakan [framework installers](https://www.python.org/ftp/python/) disediakan oleh Python Software Foundation.  Sebuah keuntungan menggunakan pemasang adalah bahwa Python macOS akan tetap "pristine"  untuk penggunaan sistem operasi internal.

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

#### Postgres.app

[Postgres.app](https://postgresapp.com/) adalah sebuah peladen PostgreSQL berdisi sendiri yang menyertakan tambahan PostGIS. Anda akan juga butuh memasang `gdal` dan `libgeoip` dengan [Homebrew](#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

[Homebrew](https://brew.sh/) menyediakan "recipes" untuk membangun biner dan paket dari sumber. itu menyediakan resep-resep untuk prasyarat GeoDjango pada komputer Macintosh menjalankan macOS. Karena Homebrew masih membangun perangkat lunak dari sumber, [Xcode](https://developer.apple.com/xcode/) diwajibkan.

Ringkasan:

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

##### Fink

[Kurt Schwehr](https://schwehr.blogspot.com/) telah cukup ramah membuat paket-paket GeoDjango untuk pengguna dari sistem paket [Fink](https://www.finkproject.org/). [Different packages are available](https://pdb.finkproject.org/pdb/browse.php?summary=django-gis) (dimulai dengan `django-gis`), bergantung pada versi mana dari Python anda ingin gunakan.

#### MacPorts

[MacPorts](https://www.macports.org/) mungkin digunakan untuk memasang prasyarat GeoDjango pada komputer berjalan macOS.  Karena MacPorts masih membangun perangakat lunak dari sumber, [Xcode](https://developer.apple.com/xcode/) diwajibkan.

Ringkasan:

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

### Windows

Proceed through the following sections sequentially in order to install
GeoDjango on Windows. In this tutorial we will install 64 bit versions of each
application.

#### Python

Install a 64 bit version of Python. See [Install Python](/id/5.2/howto/windows/)
for further information.

#### PostgreSQL

Download the latest [PostgreSQL 15.x installer](https://www.enterprisedb.com/downloads/postgres-postgresql-downloads) from the
[EnterpriseDB](https://www.enterprisedb.com) website.  After downloading, run the installer, follow the
on-screen directions, and keep the default options unless you know the
consequences of changing them.

> **Note**
>
> The PostgreSQL installer creates a new `postgres` database superuser
> You will be prompted once to set the password -- make sure to remember it!

When the installer completes, it will ask to "Launch Stack Builder at exit?" --
keep this checked, as it is necessary to install [PostGIS](#postgisasb).

> **Note**
>
> If installed successfully, the PostgreSQL server will run in the background
> each time the system as started as a Windows service. A
> PostgreSQL 15 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.

#### PostGIS

From within the Stack Builder (to run outside of the installer,
Start ‣ PostgreSQL 15 ‣ Application Stack Builder), select
PostgreSQL 15 (x64) on port 5432 from the drop down
menu and click next. Expand the
Categories ‣ Spatial Extensions menu tree and select
PostGIS X.Y for PostgreSQL 15.

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 four Yes/No dialog boxes,
the default option for all four is "No".

#### OSGeo4W

The [OSGeo4W installer](https://trac.osgeo.org/osgeo4w/) helps to install the PROJ, 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. If any other packages are
enabled by default, they are 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.

#### Merubah lingkungan Windows

In order to use GeoDjango, you will need to add your 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. Restart your device
once this is complete for new environment variables to be recognized:

```bat
set OSGEO4W_ROOT=C:\OSGeo4W
set GDAL_DATA=%OSGEO4W_ROOT%\apps\gdal\share\gdal
set PROJ_LIB=%OSGEO4W_ROOT%\share\proj
set PATH=%PATH%;%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, 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.

> **Note**
>
> Jika anda menyesuaikan direktori pemasangan OSGeo4W, anda akan butuh merubah variabel `OSGEO4W_ROOT` sesuai dengan itu.

#### Pasang Django dan setel basisdata

[Install Django](/id/5.2/topics/install/#installing-official-release) di sistem anda. Dianjurkan bahwa anda membuat [virtual environment](https://docs.python.org/3/tutorial/venv.html) untuk setiap proyek anda buat.

#### psycopg

The `psycopg` Python module provides the interface between Python and the
PostgreSQL database. `psycopg` can be installed via pip within your Python
virtual environment:

```doscon
...\> py -m pip install psycopg
```

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