{"title":"GeoDjango のインストール","version":"6.0","locale":"ja","docname":"ref/contrib/gis/install/index","url":"/ja/6.0/ref/contrib/gis/install/","canonical":"https://djangodocs.dev/ja/6.0/ref/contrib/gis/install/","summary":"通常、GeoDjango のインストールには次のものが必要です: Python と Django, 空間データベース (Spatial database), 地理空間ライブラリ (Geospatial library).","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/6.0/ref/contrib/gis/install/geolibs/#geolibs-list\"><span class=\"std std-ref\">地理空間ライブラリ (Geospatial library)</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\" role=\"note\">\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/6.0/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>The geospatial libraries required for a GeoDjango installation depends\non the spatial database used. The following lists the library requirements,\nsupported versions, and any notes for each of the supported database backends:</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>14+</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/6.0/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/6.0/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/6.0/ref/contrib/gis/install/postgis/\">PostGIS のインストール</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/ja/6.0/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/6.0/ref/settings/#std-setting-DATABASES\"><code class=\"xref std std-setting docutils literal notranslate\">DATABASES</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/6.0/ref/settings/#std-setting-DATABASE-ENGINE\"><code class=\"xref std std-setting docutils literal notranslate\">ENGINE</code></a> 設定を、<a class=\"reference internal\" href=\"/ja/6.0/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\">django.contrib.gis</code> を <a class=\"reference internal\" href=\"/ja/6.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</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/6.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> に <a class=\"reference internal\" href=\"/ja/6.0/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\">django.contrib.gis</code></a> を追加するだけです。これは <code class=\"docutils literal notranslate\">gis</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>File a ticket on the <a class=\"reference external\" href=\"https://code.djangoproject.com/newticket\">Django trac</a> if you think there's a bug. Make\nsure to provide a complete description of the problem, versions used,\nand specify the component as &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\">LD_LIBRARY_PATH</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>A user may set this environment variable to customize the library paths\nthey want to use. The typical library directory for software\nbuilt from source is <code class=\"docutils literal notranslate\">/usr/local/lib</code>. Thus, <code class=\"docutils literal notranslate\">/usr/local/lib</code> needs\nto be included in the <code class=\"docutils literal notranslate\">LD_LIBRARY_PATH</code> variable. For example, the user\ncould place the following in their bash profile:</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=\"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>On GNU/Linux systems, there is typically a file in <code class=\"docutils literal notranslate\">/etc/ld.so.conf</code>, which\nmay include additional paths from files in another directory, such as\n<code class=\"docutils literal notranslate\">/etc/ld.so.conf.d</code>. As the root user, add the custom library path (like\n<code class=\"docutils literal notranslate\">/usr/local/lib</code>) on a new line in <code class=\"docutils literal notranslate\">ld.so.conf</code>. This is <em>one</em> example of\nhow to do so:</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>$ sudo <span class=\"nb\">echo</span> /usr/local/lib &gt;&gt; /etc/ld.so.conf\n$ sudo ldconfig\n</code></pre></div>\n<p>For OpenSolaris users, the system library path may be modified using the\n<code class=\"docutils literal notranslate\">crle</code> utility. Run <code class=\"docutils literal notranslate\">crle</code> with no options to see the current configuration\nand use <code class=\"docutils literal notranslate\">crle -l</code> to set with the new library path. Be <em>very</em> careful when\nmodifying the system library path:</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\">binutils</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 uses the <code class=\"docutils literal notranslate\">find_library</code> function (from the <code class=\"docutils literal notranslate\">ctypes.util</code> Python\nmodule) to discover libraries. The <code class=\"docutils literal notranslate\">find_library</code> routine uses a program\ncalled <code class=\"docutils literal notranslate\">objdump</code> (part of the <code class=\"docutils literal notranslate\">binutils</code> package) to verify a shared\nlibrary on GNU/Linux systems. Thus, if <code class=\"docutils literal notranslate\">binutils</code> is not installed on your\nLinux system then Python's ctypes may not be able to find your library even if\nyour library path is set correctly and geospatial libraries were built\nperfectly.</p>\n<p><code class=\"docutils literal notranslate\">binutils</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>$ sudo apt-get install 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>$ sudo yum install 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/6.0/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>Although macOS comes with Python installed, users can use <a class=\"reference external\" href=\"https://www.python.org/ftp/python/\">framework\ninstallers</a> provided by the Python Software Foundation. An advantage to\nusing the installer is that macOS's Python will remain &quot;pristine&quot; for internal\noperating system use.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>コマンドラインで <code class=\"docutils literal notranslate\">python</code> を入力したときに新しいバージョンの Python が使われるように、<code class=\"docutils literal notranslate\">.profile</code> ファイルの <code class=\"docutils literal notranslate\">PATH</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=\"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> is a standalone PostgreSQL server\nthat includes the PostGIS extension. You will also need to install <code class=\"docutils literal notranslate\">gdal</code>\nwith <a class=\"reference internal\" href=\"#homebrew\"><span class=\"std std-ref\">Homebrew</span></a>.</p>\n<p>Postgres.appをインストールした後、コマンドラインからパッケージのプログラムを実行できるように、 <code class=\"docutils literal notranslate\">.bash_profile</code> に以下を追加してください。 <code class=\"docutils literal notranslate\">X.Y</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=\"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\">which psql</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>$ brew install postgresql\n$ brew install postgis\n$ brew install gdal\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\">django-gis</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> may be used to install GeoDjango prerequisites on computers\nrunning macOS. Because MacPorts still builds the software from source,\n<a class=\"reference external\" href=\"https://developer.apple.com/xcode/\">Xcode</a> is required.</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>$ sudo port install postgresql14-server\n$ sudo port install geos\n$ sudo port install proj6\n$ sudo port install postgis3\n$ sudo port install gdal\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\">.profile</code> の <code class=\"docutils literal notranslate\">PATH</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=\"nv\">PATH</span><span class=\"o\">=</span>/opt/local/bin:/opt/local/lib/postgresql14/bin\n</code></pre></div>\n<p>さらに、Python がライブラリを見つけられるように、 <code class=\"docutils literal notranslate\">DYLD_FALLBACK_LIBRARY_PATH</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=\"nv\">DYLD_FALLBACK_LIBRARY_PATH</span><span class=\"o\">=</span>/opt/local/lib:/opt/local/lib/postgresql14\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/6.0/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>Download the latest <a class=\"reference external\" href=\"https://www.enterprisedb.com/downloads/postgres-postgresql-downloads\">PostgreSQL 15.x installer</a> from the\n<a class=\"reference external\" href=\"https://www.enterprisedb.com\">EnterpriseDB</a> website. After downloading, run the installer, follow the\non-screen directions, and keep the default options unless you know the\nconsequences of changing them.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">注釈</p>\n<p>PostgreSQL のインストーラーは新しい <code class=\"docutils literal notranslate\">postgres</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>If installed successfully, the PostgreSQL server will run in the background\neach time the system is started as a Windows service. A\n<span class=\"menuselection\">PostgreSQL 15</span> start menu group will created and contains\nshortcuts for the Application Stack Builder (ASB) as well as the\n'SQL Shell', which will launch a <code class=\"docutils literal notranslate\">psql</code> command window.</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>The <a class=\"reference external\" href=\"https://trac.osgeo.org/osgeo4w/\">OSGeo4W installer</a> helps to install the PROJ, GDAL, and GEOS libraries\nrequired by GeoDjango. First, download the <a class=\"reference external\" href=\"https://trac.osgeo.org/osgeo4w/\">OSGeo4W installer</a>, and\nrun it. Select <span class=\"menuselection\">Express Web-GIS Install</span> and click next. In the\n'Select Packages' list, ensure that GDAL is selected. If any other packages are\nenabled by default, they are not required by GeoDjango and may be unchecked\nsafely. After clicking next and accepting the license agreements, the packages\nwill be automatically downloaded and installed, after which you may exit the\ninstaller.</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>In order to use GeoDjango, you will need to add your OSGeo4W\ndirectories to your Windows system <code class=\"docutils literal notranslate\">Path</code>, as well as create <code class=\"docutils literal notranslate\">GDAL_DATA</code>\nand <code class=\"docutils literal notranslate\">PROJ_LIB</code> environment variables. The following set of commands,\nexecutable with <code class=\"docutils literal notranslate\">cmd.exe</code>, will set this up. Restart your device\nonce this is complete for new environment variables to be recognized:</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\">OSGEO4W_ROOT</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/6.0/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\">psycopg</code> は Python と PostgreSQL  データベースのインターフェースを提供します。 <code class=\"docutils literal notranslate\">psycopg</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\">ctypes.util</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\">find_library()</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/6.0/ref/"},{"docname":"ref/contrib/index","title":"contrib パッケージ","url":"/ja/6.0/ref/contrib/"},{"docname":"ref/contrib/gis/index","title":"GeoDjango","url":"/ja/6.0/ref/contrib/gis/"}],"prev":{"docname":"ref/contrib/gis/tutorial","title":"GeoDjango チュートリアル","url":"/ja/6.0/ref/contrib/gis/tutorial/"},"next":{"docname":"ref/contrib/gis/install/geolibs","title":"地理空間ライブラリのインストール","url":"/ja/6.0/ref/contrib/gis/install/geolibs/"},"formats":{"html":"/ja/6.0/ref/contrib/gis/install/","markdown":"/ja/6.0/ref/contrib/gis/install.md","json":"/ja/6.0/ref/contrib/gis/install.json"},"source":"https://github.com/django/django/blob/stable/6.0.x/docs/ref/contrib/gis/install/index.txt","official":"https://docs.djangoproject.com/ja/6.0/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","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}