{"title":"GeoDjango のインストール","version":"5.1","locale":"ja","docname":"ref/contrib/gis/install/index","url":"/ja/5.1/ref/contrib/gis/install/","canonical":"https://djangodocs.dev/ja/5.1/ref/contrib/gis/install/","summary":"概要 Link to this heading # 通常、GeoDjango のインストールには次のものが必要です: Python と Django 空間データベース (Spatial database) 地理空間ライブラリのインストール…","html":"<h1>GeoDjango のインストール<a class=\"heading-anchor\" href=\"#geodjango-installation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<section id=\"overview\">\n<h2>概要<a class=\"heading-anchor\" href=\"#overview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>通常、GeoDjango のインストールには次のものが必要です:</p>\n<ol class=\"arabic simple\">\n<li><p><a class=\"reference internal\" href=\"#django\"><span class=\"std std-ref\">Python と Django</span></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#spatial-database\"><span class=\"std std-ref\">空間データベース (Spatial database)</span></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/ja/5.1/ref/contrib/gis/install/geolibs/\"><span class=\"doc\">地理空間ライブラリのインストール</span></a></p></li>\n</ol>\n<p>各要件の詳細とインストール手順については、以下のセクションを参照してください。また、プラットフォーム別の手順もあります:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"#macos\"><span class=\"std std-ref\">macOS</span></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#windows\"><span class=\"std std-ref\">Windows</span></a></p></li>\n</ul>\n<aside class=\"admonition-use-the-source admonition\">\n<p class=\"admonition-title\">ソースを使う</p>\n<p>GeoDjango はオープンソースの地理空間ソフトウェア技術を最新のものを活用しているため、最新バージョンのライブラリが必要です。プラットフォームにバイナリパッケージが提供されていない場合は、ソースからのインストールが必要になるかもしれません。ソースからライブラリをコンパイルする際には、特に初心者の場合は指示に注意してください。</p>\n</aside>\n</section>\n<section id=\"requirements\">\n<h2>必要条件<a class=\"heading-anchor\" href=\"#requirements\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"python-and-django\">\n<span id=\"django\"></span><h3>Python と Django<a class=\"heading-anchor\" href=\"#python-and-django\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>GeoDjango は Django に同梱されていますので、インストール方法の詳細は Django の <a class=\"reference internal\" href=\"/ja/5.1/topics/install/#installing-official-release\"><span class=\"std std-ref\">インストール手順</span></a> を参照してください。</p>\n</section>\n<section id=\"spatial-database\">\n<span id=\"id1\"></span><h3>空間データベース (Spatial database)<a class=\"heading-anchor\" href=\"#spatial-database\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>現在サポートされている空間データベースは、PostgreSQL (with PostGIS)、MySQL、Oracle、SQLite (with SpatiaLite) です。</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>PostGISは、最も成熟した機能豊富なオープンソースの空間データベースであるため、推奨されています。</p>\n</aside>\n<p>GeoDjango のインストールに必要な地理空間ライブラリは、使用する空間データベースによって異なります。以下は、サポートされているデータベースバックエンドごとに、必要なライブラリ、サポートされているバージョン、および注意事項 の一覧です:</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p>データベース</p></th>\n<th class=\"head\"><p>ライブラリの要件</p></th>\n<th class=\"head\"><p>サポートされるバージョン</p></th>\n<th class=\"head\"><p>備考</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p>PostgreSQL</p></td>\n<td><p>GEOS, GDAL, PROJ, PostGIS</p></td>\n<td><p>13+</p></td>\n<td><p>PostGIS が必要です。</p></td>\n</tr>\n<tr class=\"row-odd\"><td><p>MySQL</p></td>\n<td><p>GEOS, GDAL</p></td>\n<td><p>8.0.11+</p></td>\n<td><p><a class=\"reference internal\" href=\"/ja/5.1/ref/contrib/gis/db-api/#mysql-spatial-limitations\"><span class=\"std std-ref\">機能制限があります</span></a> 。</p></td>\n</tr>\n<tr class=\"row-even\"><td><p>Oracle</p></td>\n<td><p>GEOS, GDAL</p></td>\n<td><p>19+</p></td>\n<td><p>XE not supported.</p></td>\n</tr>\n<tr class=\"row-odd\"><td><p>SQLite</p></td>\n<td><p>GEOS, GDAL, PROJ, SpatiaLite</p></td>\n<td><p>3.31.0+</p></td>\n<td><p>Requires SpatiaLite 4.3+</p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>PostgreSQL/PostGIS/GEOS/GDAL の可能な組み合わせについては、OSGeo Wikiの <a class=\"reference external\" href=\"https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS\">this comparison matrix</a> も参照してください。</p>\n</section>\n</section>\n<section id=\"installation\">\n<h2>インストール<a class=\"heading-anchor\" href=\"#installation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"geospatial-libraries\">\n<h3>地理空間ライブラリ (Geospatial library)<a class=\"heading-anchor\" href=\"#geospatial-libraries\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<div class=\"toctree-wrapper compound\">\n<ul>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/ja/5.1/ref/contrib/gis/install/geolibs/\">地理空間ライブラリのインストール</a></li>\n</ul>\n</div>\n</section>\n<section id=\"database-installation\">\n<h3>データベースのインストール<a class=\"heading-anchor\" href=\"#database-installation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<div class=\"toctree-wrapper compound\">\n<ul>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/ja/5.1/ref/contrib/gis/install/postgis/\">PostGIS のインストール</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/ja/5.1/ref/contrib/gis/install/spatialite/\">SpatiaLite のインストール</a></li>\n</ul>\n</div>\n</section>\n<section id=\"databases-configuration\">\n<h3><a class=\"reference internal\" href=\"/ja/5.1/ref/settings/#std-setting-DATABASES\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DATABASES</span></code></a> の設定<a class=\"heading-anchor\" href=\"#databases-configuration\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p><a class=\"reference internal\" href=\"/ja/5.1/ref/settings/#std-setting-DATABASE-ENGINE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ENGINE</span></code></a> 設定を、<a class=\"reference internal\" href=\"/ja/5.1/ref/contrib/gis/db-api/#spatial-backends\"><span class=\"std std-ref\">空間 (spatial) バックエンド</span></a> の1つに設定してください。</p>\n</section>\n<section id=\"add-django-contrib-gis-to-installed-apps\">\n<h3><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.gis</span></code> を <a class=\"reference internal\" href=\"/ja/5.1/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> に追加します。<a class=\"heading-anchor\" href=\"#add-django-contrib-gis-to-installed-apps\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>他の Django contrib アプリケーションと同様に、設定の <a class=\"reference internal\" href=\"/ja/5.1/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> に <a class=\"reference internal\" href=\"/ja/5.1/ref/contrib/gis/#module-django.contrib.gis\" title=\"django.contrib.gis: Geographic Information System (GIS) extensions for Django\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">django.contrib.gis</span></code></a> を追加するだけです。これは <code class=\"docutils literal notranslate\"><span class=\"pre\">gis</span></code> テンプレートを配置するためです。そうしないと、地理管理や KML サイトマップのような機能が正しく動作しません。</p>\n</section>\n</section>\n<section id=\"troubleshooting\">\n<h2>トラブルシューティング<a class=\"heading-anchor\" href=\"#troubleshooting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>問題の解決策がここに見つからない場合は、コミュニティに参加してみてください！以下のようなことができます:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference external\" href=\"https://forum.djangoproject.com/c/internals/geodjango/13\">GeoDjango</a> フォーラムで質問してください。</p></li>\n<li><p>バグがあると思ったら <a class=\"reference external\" href=\"https://code.djangoproject.com/newticket\">Django trac</a> にチケットを提出してください。  問題の完全な説明、使用したバージョン、コンポーネントを &quot;GIS&quot; と指定してください。</p></li>\n</ul>\n<section id=\"library-environment-settings\">\n<span id=\"libsettings\"></span><h3>ライブラリの環境設定<a class=\"heading-anchor\" href=\"#library-environment-settings\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>GeoDjango をインストールする際に最もよくある問題は、外部の共有ライブラリ (例えば GEOS や GDAL) が見つからないというものです <a class=\"footnote-reference brackets\" href=\"#id22\" id=\"id5\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>1<span class=\"fn-bracket\">]</span></a> 。通常、この問題の原因は、オペレーティングシステムがソースからビルドされたライブラリがインストールされたディレクトリを認識していないことです。</p>\n<p>通常、ライブラリのパスは、個々のユーザーごとに環境変数を設定するか、システム全体のライブラリ パスを構成することで設定できます。</p>\n<section id=\"ld-library-path-environment-variable\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">LD_LIBRARY_PATH</span></code> 環境変数<a class=\"heading-anchor\" href=\"#ld-library-path-environment-variable\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>ユーザーは、使用するライブラリパスをカスタマイズするためにこの環境変数を設定できます。ソースからビルドされたソフトウェアの典型的なライブラリディレクトリは <code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/lib</span></code> です。したがって、 <code class=\"docutils literal notranslate\"><span class=\"pre\">LD_LIBRARY_PATH</span></code> 変数に <code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/lib</span></code> を含める必要があります。たとえば、ユーザーは次のような設定を bash プロファイルに記述できます:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"nb\">export</span><span class=\"w\"> </span><span class=\"nv\">LD_LIBRARY_PATH</span><span class=\"o\">=</span>/usr/local/lib\n</code></pre></div>\n</section>\n<section id=\"setting-system-library-path\">\n<h4>システムライブラリのパスを設定する<a class=\"heading-anchor\" href=\"#setting-system-library-path\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>通常、GNU/Linuxシステムでは、 <code class=\"docutils literal notranslate\"><span class=\"pre\">/etc/ld.so.conf</span></code> にファイルがあり、別のディレクトリにあるファイルから追加のパスを含むことがあります。そのディレクトリとは、例えば <code class=\"docutils literal notranslate\"><span class=\"pre\">/etc/ld.so.conf.d</span></code> です。root ユーザーとして、 <code class=\"docutils literal notranslate\"><span class=\"pre\">ld.so.conf</span></code> の新しい行にカスタムライブラリパス (例: <code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/lib</span></code> など) を追加してください。これはその <em>一つ</em> の例です:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>$<span class=\"w\"> </span>sudo<span class=\"w\"> </span><span class=\"nb\">echo</span><span class=\"w\"> </span>/usr/local/lib<span class=\"w\"> </span>&gt;&gt;<span class=\"w\"> </span>/etc/ld.so.conf\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>ldconfig\n</code></pre></div>\n<p>OpenSolaris ユーザーは、<code class=\"docutils literal notranslate\"><span class=\"pre\">crle</span></code> ユーティリティを使ってシステムライブラリのパスを変更できます。オプションなしで <code class=\"docutils literal notranslate\"><span class=\"pre\">crle</span></code> を実行すると現在の設定が表示され、 <code class=\"docutils literal notranslate\"><span class=\"pre\">crle</span> <span class=\"pre\">-l</span></code> を使用すると新しいライブラリパスが設定されます。システムライブラリパスを変更する際には、 <em>非常に</em> 注意してください:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"c1\"># crle -l $OLD_PATH:/usr/local/lib</span>\n</code></pre></div>\n</section>\n<section id=\"install-binutils\">\n<span id=\"binutils\"></span><h4><code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code> をインストールする<a class=\"heading-anchor\" href=\"#install-binutils\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>GeoDjango は <code class=\"docutils literal notranslate\"><span class=\"pre\">find_library</span></code> 関数 (<code class=\"docutils literal notranslate\"><span class=\"pre\">ctypes.util</span></code> Python モジュールのもの) を使ってライブラリを検出します。 <code class=\"docutils literal notranslate\"><span class=\"pre\">find_library</span></code> ルーチンは <code class=\"docutils literal notranslate\"><span class=\"pre\">objdump</span></code> というプログラム (<code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code> パッケージの一部) を使って、GNU/Linux システム上の共有ライブラリを確認します。そのため、もし <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code> が Linux システムにインストールされていない場合、ライブラリパスが正しく設定され、地理空間ライブラリが完璧にビルドされていたとしても、Python の ctypes はライブラリを見つけることができないかもしれません。</p>\n<p><code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code> パッケージは、Debian および Ubuntu システムでは以下のコマンドを使用してインストールできます:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>apt-get<span class=\"w\"> </span>install<span class=\"w\"> </span>binutils\n</code></pre></div>\n<p>Red Hat および CentOS システムでも同様です:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>yum<span class=\"w\"> </span>install<span class=\"w\"> </span>binutils\n</code></pre></div>\n</section>\n</section>\n</section>\n<section id=\"platform-specific-instructions\">\n<h2>プラットフォーム固有の手順<a class=\"heading-anchor\" href=\"#platform-specific-instructions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"macos\">\n<span id=\"id6\"></span><h3>macOS<a class=\"heading-anchor\" href=\"#macos\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>macOS では様々なパッケージングシステムが利用できるため、ユーザは GeoDjango をインストールするのにいくつかの異なる選択肢があります。これらのオプションは以下の通りです:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"#postgresapp\"><span class=\"std std-ref\">Postgres.app</span></a> (最も簡単、推奨)</p></li>\n<li><p><a class=\"reference internal\" href=\"#homebrew\"><span class=\"std std-ref\">Homebrew</span></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#fink\"><span class=\"std std-ref\">Fink</span></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#macports\"><span class=\"std std-ref\">MacPorts</span></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/ja/5.1/ref/contrib/gis/install/geolibs/#build-from-source\"><span class=\"std std-ref\">ソースコードからビルドする</span></a></p></li>\n</ul>\n<p>このセクションには、Python Software Foundation が提供するパッケージから <a class=\"reference internal\" href=\"#macos-python\"><span class=\"std std-ref\">Python</span></a> のアップグレード版をインストールする手順も含まれていますが、これは必須ではありません。</p>\n<section id=\"python\">\n<span id=\"macos-python\"></span><h4>Python<a class=\"heading-anchor\" href=\"#python\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>macOSにはPythonがインストールされていますが、Python Software Foundation が提供する <a class=\"reference external\" href=\"https://www.python.org/ftp/python/\">framework installers</a> を使用することもできます。インストーラーを使用する利点は、macOSのPythonがOS内部で使用するために &quot;原始的&quot; なままであることです。</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>コマンドラインで <code class=\"docutils literal notranslate\"><span class=\"pre\">python</span></code> を入力したときに新しいバージョンの Python が使われるように、<code class=\"docutils literal notranslate\"><span class=\"pre\">.profile</span></code> ファイルの <code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> 環境変数を変更する必要があります:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"nb\">export</span><span class=\"w\"> </span><span class=\"nv\">PATH</span><span class=\"o\">=</span>/Library/Frameworks/Python.framework/Versions/Current/bin:<span class=\"nv\">$PATH</span>\n</code></pre></div>\n</aside>\n</section>\n<section id=\"postgres-app\">\n<span id=\"postgresapp\"></span><h4>Postgres.app<a class=\"heading-anchor\" href=\"#postgres-app\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference external\" href=\"https://postgresapp.com/\">Postgres.app</a> は PostGIS 拡張を含むスタンドアロンの PostgreSQL サーバです。また、<code class=\"docutils literal notranslate\"><span class=\"pre\">gdal</span></code> と <code class=\"docutils literal notranslate\"><span class=\"pre\">libgeoip</span></code> を <a class=\"reference internal\" href=\"#homebrew\"><span class=\"std std-ref\">Homebrew</span></a> と共にインストールする必要があります。</p>\n<p>Postgres.appをインストールした後、コマンドラインからパッケージのプログラムを実行できるように、 <code class=\"docutils literal notranslate\"><span class=\"pre\">.bash_profile</span></code> に以下を追加してください。 <code class=\"docutils literal notranslate\"><span class=\"pre\">X.Y</span></code> をインストールした Postgres.app の PostgreSQL のバージョンに置き換えてください:</p>\n<div class=\"code-block\" data-language=\"bash\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"nb\">export</span><span class=\"w\"> </span><span class=\"nv\">PATH</span><span class=\"o\">=</span><span class=\"nv\">$PATH</span>:/Applications/Postgres.app/Contents/Versions/X.Y/bin\n</code></pre></div>\n<p>ターミナルプロンプトで <code class=\"docutils literal notranslate\"><span class=\"pre\">which</span> <span class=\"pre\">psql</span></code> と入力して、パスが正しく設定されているかを確認できます。</p>\n</section>\n<section id=\"homebrew\">\n<span id=\"id9\"></span><h4>Homebrew<a class=\"heading-anchor\" href=\"#homebrew\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference external\" href=\"https://brew.sh/\">Homebrew</a> は、ソースコードからバイナリおよびパッケージを構築するための「レシピ」を提供します。これは、macOS を実行している Macintosh コンピュータ上で GeoDjango の前提条件のためのレシピを提供しています。Homebrew はソフトウェアをソースコードから構築するため、 <a class=\"reference external\" href=\"https://developer.apple.com/xcode/\">Xcode</a> が必要となります。</p>\n<p>概要:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>$<span class=\"w\"> </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>postgresql\n$<span class=\"w\"> </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>postgis\n$<span class=\"w\"> </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>gdal\n$<span class=\"w\"> </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>libgeoip\n</code></pre></div>\n<section id=\"fink\">\n<span id=\"id11\"></span><h5>Fink<a class=\"heading-anchor\" href=\"#fink\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h5>\n<p><a class=\"reference external\" href=\"https://schwehr.blogspot.com/\">Kurt Schwehr</a> は <a class=\"reference external\" href=\"https://www.finkproject.org/\">Fink</a> パッケージシステムのユーザーのために GeoDjango パッケージを作成してくれました。使用したい Python のバージョンに応じて、<a class=\"reference external\" href=\"https://pdb.finkproject.org/pdb/browse.php?summary=django-gis\">Different packages are available</a> です（<code class=\"docutils literal notranslate\"><span class=\"pre\">django-gis</span></code> から始まります）。</p>\n</section>\n</section>\n<section id=\"macports\">\n<span id=\"id15\"></span><h4>MacPorts<a class=\"heading-anchor\" href=\"#macports\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference external\" href=\"https://www.macports.org/\">MacPorts</a> を使うと、macOS を実行しているコンピュータに GeoDjango の依存関係をインストールできます。MacPorts はソフトウェアをソースからビルドするので、 <a class=\"reference external\" href=\"https://developer.apple.com/xcode/\">Xcode</a> が必要です。</p>\n<p>概要:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>postgresql13-server\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>geos\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>proj6\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>postgis3\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>gdal\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>libgeoip\n</code></pre></div>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>また、MacPorts のプログラムにコマンドラインからアクセスできるように、 <code class=\"docutils literal notranslate\"><span class=\"pre\">.profile</span></code> の <code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> を変更する必要があります:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"nb\">export</span><span class=\"w\"> </span><span class=\"nv\">PATH</span><span class=\"o\">=</span>/opt/local/bin:/opt/local/lib/postgresql13/bin\n</code></pre></div>\n<p>さらに、Python がライブラリを見つけられるように、 <code class=\"docutils literal notranslate\"><span class=\"pre\">DYLD_FALLBACK_LIBRARY_PATH</span></code> 設定を追加してください:</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"nb\">export</span><span class=\"w\"> </span><span class=\"nv\">DYLD_FALLBACK_LIBRARY_PATH</span><span class=\"o\">=</span>/opt/local/lib:/opt/local/lib/postgresql13\n</code></pre></div>\n</aside>\n</section>\n</section>\n<section id=\"windows\">\n<span id=\"id17\"></span><h3>Windows<a class=\"heading-anchor\" href=\"#windows\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>GeoDjango を Windows にインストールするには、以下のセクションを順番に進めてください。このチュートリアルでは、各アプリケーションの 64 ビット版をインストールします。</p>\n<section id=\"id18\">\n<h4>Python<a class=\"heading-anchor\" href=\"#id18\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>64ビット版のPythonをインストールします。詳しくは <a class=\"reference internal\" href=\"/ja/5.1/howto/windows/\"><span class=\"doc\">Python のインストール</span></a> を参照してください。</p>\n</section>\n<section id=\"postgresql\">\n<h4>PostgreSQL<a class=\"heading-anchor\" href=\"#postgresql\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference external\" href=\"https://www.enterprisedb.com/downloads/postgres-postgresql-downloads\">EnterpriseDB</a> のウェブサイトから最新の <a class=\"reference external\" href=\"https://www.enterprisedb.com\">PostgreSQL 15.x installer</a> をダウンロードしてください。ダウンロード後、インストーラーを実行し、画面の指示に従い、デフォルトのオプションを変更するリスクを理解していない限り、変更せずに進んでください。</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>PostgreSQL のインストーラーは新しい <code class=\"docutils literal notranslate\"><span class=\"pre\">postgres</span></code> データベース管理者ユーザーを作成します。パスワードを設定する際に一度だけ入力を求められます。それを忘れないようにしてください！</p>\n</aside>\n<p>インストーラーが完了すると、 &quot;Launch Stack Builder at exit?&quot; （スタックビルダーを終了時に起動しますか？）という質問が表示されます。これは、<a class=\"reference internal\" href=\"#postgisasb\"><span class=\"std std-ref\">PostGIS</span></a> をインストールするために必要ですので、チェックを入れたままにしてください。</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>インストールが成功すると、PostgreSQL サーバーは Windows サービスとしてシステムが起動するたびにバックグラウンドで実行されます。 <span class=\"menuselection\">PostgreSQL 15</span> スタートメニューグループが作成され、アプリケーションスタックビルダー (ASB) および &quot;SQL Shell&quot; のショートカットが含まれます。 &quot;SQL Shell&quot; を起動すると <code class=\"docutils literal notranslate\"><span class=\"pre\">psql</span></code> コマンドウィンドウが開きます。</p>\n</aside>\n</section>\n<section id=\"postgis\">\n<span id=\"postgisasb\"></span><h4>PostGIS<a class=\"heading-anchor\" href=\"#postgis\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Stack Builder (インストーラの外で実行するには <span class=\"menuselection\">Start ‣ PostgreSQL 15 ‣ Application Stack Builder</span> ) から、ドロップダウンメニューから <span class=\"menuselection\">PostgreSQL 15 (x64) on port 5432</span> を選択して next をクリックします。 <span class=\"menuselection\">Categories ‣ Spatial Extensions</span> メニューツリーを展開し、 <span class=\"menuselection\">PostGIS X.Y for PostgreSQL 15</span> を選択します。</p>\n<p>next をクリックすると、選択したパッケージと &quot;Download directory&quot; を確認するプロンプトが表示されます。もう一度 next をクリックすると、PostGIS がダウンロードされ、next をクリックして PostGIS のインストーラを開始するよう求められます。インストール中はデフォルトのオプションを選択してください。インストールプロセスでは、4つの Yes/No ダイアログボックスが表示されます。</p>\n</section>\n<section id=\"osgeo4w\">\n<span id=\"id21\"></span><h4>OSGeo4W<a class=\"heading-anchor\" href=\"#osgeo4w\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference external\" href=\"https://trac.osgeo.org/osgeo4w/\">OSGeo4W installer</a> は GeoDjango で必要な PROJ、GDAL、GEOS ライブラリのインストールに役立ちます。まず、 <a class=\"reference external\" href=\"https://trac.osgeo.org/osgeo4w/\">OSGeo4W installer</a> をダウンロードし、実行します。 <span class=\"menuselection\">Express Web-GIS Install</span> を選択し、next をクリックします。 &quot;Select Packages&quot; リストで、GDAL が選択されていることを確認してください。他のパッケージがデフォルトで有効になっている場合、それらは GeoDjango には必要ないので、チェックを外しても大丈夫です。次へをクリックし、ライセンス契約に同意すると、パッケージが自動的にダウンロードされ、インストールされます。</p>\n</section>\n<section id=\"modify-windows-environment\">\n<h4>Windows 環境変数の変更<a class=\"heading-anchor\" href=\"#modify-windows-environment\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>GeoDjangoを使用するには、Windowsシステムの <code class=\"docutils literal notranslate\"><span class=\"pre\">Path</span></code> に OSGeo4W ディレクトリを追加し、 <code class=\"docutils literal notranslate\"><span class=\"pre\">GDAL_DATA</span></code> と <code class=\"docutils literal notranslate\"><span class=\"pre\">PROJ_LIB</span></code> の環境変数を作成する必要があります。以下のコマンドセットは、 <code class=\"docutils literal notranslate\"><span class=\"pre\">cmd.exe</span></code> で実行可能で、これを設定します。新しい環境変数を認識させるために、この作業が完了したらデバイスを再起動してください。</p>\n<div class=\"code-block\" data-language=\"bat\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Bat</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Bat code\"><code><span class=\"k\">set</span> <span class=\"nv\">OSGEO4W_ROOT</span><span class=\"p\">=</span>C:\\OSGeo4W\n<span class=\"k\">set</span> <span class=\"nv\">GDAL_DATA</span><span class=\"p\">=</span><span class=\"nv\">%OSGEO4W_ROOT%</span>\\apps\\gdal\\share\\gdal\n<span class=\"k\">set</span> <span class=\"nv\">PROJ_LIB</span><span class=\"p\">=</span><span class=\"nv\">%OSGEO4W_ROOT%</span>\\share\\proj\n<span class=\"k\">set</span> <span class=\"nv\">PATH</span><span class=\"p\">=</span><span class=\"nv\">%PATH%</span>;<span class=\"nv\">%OSGEO4W_ROOT%</span>\\bin\nreg ADD <span class=\"s2\">&quot;HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment&quot;</span> /v Path /t REG_EXPAND_SZ /f /d <span class=\"s2\">&quot;</span><span class=\"nv\">%PATH%</span><span class=\"s2\">&quot;</span>\nreg ADD <span class=\"s2\">&quot;HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment&quot;</span> /v GDAL_DATA /t REG_EXPAND_SZ /f /d <span class=\"s2\">&quot;</span><span class=\"nv\">%GDAL_DATA%</span><span class=\"s2\">&quot;</span>\nreg ADD <span class=\"s2\">&quot;HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment&quot;</span> /v PROJ_LIB /t REG_EXPAND_SZ /f /d <span class=\"s2\">&quot;</span><span class=\"nv\">%PROJ_LIB%</span><span class=\"s2\">&quot;</span>\n</code></pre></div>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>これらのコマンドを実行するには、管理者権限が必要です。これを行うには、管理者としてコマンドプロンプトを実行し、上記のコマンドを入力します。設定を有効にするには、一旦ログアウトし、再度ログインする必要があります。</p>\n</aside>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>OSGeo4W のインストールディレクトリをカスタマイズした場合、それに応じて <code class=\"docutils literal notranslate\"><span class=\"pre\">OSGEO4W_ROOT</span></code> 変数を変更する必要があります。</p>\n</aside>\n</section>\n<section id=\"install-django-and-set-up-database\">\n<h4>Djangoのインストールとデータベースのセットアップ<a class=\"heading-anchor\" href=\"#install-django-and-set-up-database\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>システムにDjangoを <a class=\"reference internal\" href=\"/ja/5.1/topics/install/#installing-official-release\"><span class=\"std std-ref\">インストール</span></a> します。作成する各プロジェクトに対して <a class=\"reference external\" href=\"https://docs.python.org/3/tutorial/venv.html\" title=\"(in Python v3.14)\"><span class=\"xref std std-doc\">仮想環境</span></a> を作成することを推奨します。</p>\n</section>\n<section id=\"psycopg\">\n<h4>psycopg<a class=\"heading-anchor\" href=\"#psycopg\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Pythonモジュール <code class=\"docutils literal notranslate\"><span class=\"pre\">psycopg</span></code> は Python と PostgreSQL  データベースのインターフェースを提供します。 <code class=\"docutils literal notranslate\"><span class=\"pre\">psycopg</span></code> は Python 仮想環境内で pip を使用してインストールできます:</p>\n<div class=\"code-block\" data-language=\"doscon\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Windows</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Windows code\"><code><span class=\"gp\">...\\&gt;</span> py -m pip install psycopg\n</code></pre></div>\n<p class=\"rubric\">脚注</p>\n<aside class=\"footnote-list brackets\">\n<aside class=\"footnote brackets\" id=\"id22\" role=\"doc-footnote\">\n<span class=\"label\"><span class=\"fn-bracket\">[</span><a role=\"doc-backlink\" href=\"#id5\">1</a><span class=\"fn-bracket\">]</span></span>\n<p>GeoDjango では、共有ライブラリを探すために <code class=\"docutils literal notranslate\"><span class=\"pre\">ctypes.util</span></code> の <a class=\"reference external\" href=\"https://docs.python.org/3/library/ctypes.html#ctypes.util.find_library\" title=\"(in Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">find_library()</span></code></a> ルーチンが使用されています。</p>\n</aside>\n</aside>\n</section>\n</section>\n</section>","rootId":"geodjango-installation","toc":[{"title":"概要","anchor":"overview","children":[]},{"title":"必要条件","anchor":"requirements","children":[{"title":"Python と Django","anchor":"python-and-django","children":[]},{"title":"空間データベース (Spatial database)","anchor":"spatial-database","children":[]}]},{"title":"インストール","anchor":"installation","children":[{"title":"地理空間ライブラリ (Geospatial library)","anchor":"geospatial-libraries","children":[]},{"title":"データベースのインストール","anchor":"database-installation","children":[]},{"title":"DATABASES の設定","anchor":"databases-configuration","children":[]},{"title":"django.contrib.gis を INSTALLED_APPS に追加します。","anchor":"add-django-contrib-gis-to-installed-apps","children":[]}]},{"title":"トラブルシューティング","anchor":"troubleshooting","children":[{"title":"ライブラリの環境設定","anchor":"library-environment-settings","children":[{"title":"LD_LIBRARY_PATH 環境変数","anchor":"ld-library-path-environment-variable","children":[]},{"title":"システムライブラリのパスを設定する","anchor":"setting-system-library-path","children":[]},{"title":"binutils をインストールする","anchor":"install-binutils","children":[]}]}]},{"title":"プラットフォーム固有の手順","anchor":"platform-specific-instructions","children":[{"title":"macOS","anchor":"macos","children":[{"title":"Python","anchor":"python","children":[]},{"title":"Postgres.app","anchor":"postgres-app","children":[]},{"title":"Homebrew","anchor":"homebrew","children":[{"title":"Fink","anchor":"fink","children":[]}]},{"title":"MacPorts","anchor":"macports","children":[]}]},{"title":"Windows","anchor":"windows","children":[{"title":"Python","anchor":"id18","children":[]},{"title":"PostgreSQL","anchor":"postgresql","children":[]},{"title":"PostGIS","anchor":"postgis","children":[]},{"title":"OSGeo4W","anchor":"osgeo4w","children":[]},{"title":"Windows 環境変数の変更","anchor":"modify-windows-environment","children":[]},{"title":"Djangoのインストールとデータベースのセットアップ","anchor":"install-django-and-set-up-database","children":[]},{"title":"psycopg","anchor":"psycopg","children":[]}]}]}],"breadcrumbs":[{"docname":"ref/index","title":"API リファレンス","url":"/ja/5.1/ref/"},{"docname":"ref/contrib/index","title":"contrib パッケージ","url":"/ja/5.1/ref/contrib/"},{"docname":"ref/contrib/gis/index","title":"GeoDjango","url":"/ja/5.1/ref/contrib/gis/"}],"prev":{"docname":"ref/contrib/gis/tutorial","title":"GeoDjango チュートリアル","url":"/ja/5.1/ref/contrib/gis/tutorial/"},"next":{"docname":"ref/contrib/gis/install/geolibs","title":"地理空間ライブラリのインストール","url":"/ja/5.1/ref/contrib/gis/install/geolibs/"},"formats":{"html":"/ja/5.1/ref/contrib/gis/install/","markdown":"/ja/5.1/ref/contrib/gis/install.md","json":"/ja/5.1/ref/contrib/gis/install.json"},"source":"https://github.com/django/django/blob/stable/5.1.x/docs/ref/contrib/gis/install/index.txt","official":"https://docs.djangoproject.com/ja/5.1/ref/contrib/gis/install/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}