{"title":"GeoDjango Installation","version":"4.1","locale":"pt-br","docname":"ref/contrib/gis/install/index","url":"/pt-br/4.1/ref/contrib/gis/install/","canonical":"https://djangodocs.dev/pt-br/4.1/ref/contrib/gis/install/","summary":"Visão Geral Link para este cabeçalho # In general, GeoDjango installation requires: Python e Django Spatial database Installing Geospatial libraries Details for…","html":"<h1>GeoDjango Installation<a class=\"heading-anchor\" href=\"#geodjango-installation\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h1>\n<section id=\"overview\">\n<h2>Visão Geral<a class=\"heading-anchor\" href=\"#overview\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>In general, GeoDjango installation requires:</p>\n<ol class=\"arabic simple\">\n<li><p><a class=\"reference internal\" href=\"#django\"><span class=\"std std-ref\">Python e 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=\"/pt-br/4.1/ref/contrib/gis/install/geolibs/\"><span class=\"doc\">Installing Geospatial libraries</span></a></p></li>\n</ol>\n<p>Details for each of the requirements and installation instructions\nare provided in the sections below. In addition, platform-specific\ninstructions are available for:</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\">Use the Source</p>\n<p>Because GeoDjango takes advantage of the latest in the open source geospatial\nsoftware technology, recent versions of the libraries are necessary.\nIf binary packages aren’t available for your platform, installation from\nsource may be required. When compiling the libraries from source, please\nfollow the directions closely, especially if you’re a beginner.</p>\n</aside>\n</section>\n<section id=\"requirements\">\n<h2>Requerimentos<a class=\"heading-anchor\" href=\"#requirements\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"python-and-django\">\n<span id=\"django\"></span><h3>Python e Django<a class=\"heading-anchor\" href=\"#python-and-django\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Because GeoDjango is included with Django, please refer to Django’s\n<a class=\"reference internal\" href=\"/pt-br/4.1/topics/install/#installing-official-release\"><span class=\"std std-ref\">installation instructions</span></a> for details on\nhow to install.</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 para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>PostgreSQL (with PostGIS), MySQL, Oracle, and SQLite (with SpatiaLite) are the\nspatial databases currently supported.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Nota</p>\n<p>PostGIS is recommended, because it is the most mature and feature-rich\nopen source spatial database.</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>Banco de dados</p></th>\n<th class=\"head\"><p>Library Requirements</p></th>\n<th class=\"head\"><p>Supported Versions</p></th>\n<th class=\"head\"><p>Notas</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>11+</p></td>\n<td><p>Requer 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>5.7+</p></td>\n<td><p><a class=\"reference internal\" href=\"/pt-br/4.1/ref/contrib/gis/db-api/#mysql-spatial-limitations\"><span class=\"std std-ref\">Limited functionality</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 não suportado.</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.9.0+</p></td>\n<td><p>Requires SpatiaLite 4.3+</p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>See also <a class=\"reference external\" href=\"https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS\">this comparison matrix</a> on the OSGeo Wiki for\nPostgreSQL/PostGIS/GEOS/GDAL possible combinations.</p>\n</section>\n</section>\n<section id=\"installation\">\n<h2>Instalação<a class=\"heading-anchor\" href=\"#installation\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"geospatial-libraries\">\n<h3>Bibliotecas Geospatial<a class=\"heading-anchor\" href=\"#geospatial-libraries\"><span class=\"visually-hidden\">Link para este cabeçalho</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=\"/pt-br/4.1/ref/contrib/gis/install/geolibs/\">Installing Geospatial libraries</a></li>\n</ul>\n</div>\n</section>\n<section id=\"database-installation\">\n<h3>Instalação do banco de dados<a class=\"heading-anchor\" href=\"#database-installation\"><span class=\"visually-hidden\">Link para este cabeçalho</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=\"/pt-br/4.1/ref/contrib/gis/install/postgis/\">Installing PostGIS</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/pt-br/4.1/ref/contrib/gis/install/spatialite/\">Installing SpatiaLite</a></li>\n</ul>\n</div>\n</section>\n<section id=\"databases-configuration\">\n<h3><a class=\"reference internal\" href=\"/pt-br/4.1/ref/settings/#std-setting-DATABASES\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DATABASES</span></code></a> configuration<a class=\"heading-anchor\" href=\"#databases-configuration\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Set the <a class=\"reference internal\" href=\"/pt-br/4.1/ref/settings/#std-setting-DATABASE-ENGINE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ENGINE</span></code></a> setting to one of the <a class=\"reference internal\" href=\"/pt-br/4.1/ref/contrib/gis/db-api/#spatial-backends\"><span class=\"std std-ref\">spatial\nbackends</span></a>.</p>\n</section>\n<section id=\"add-django-contrib-gis-to-installed-apps\">\n<h3>Add <code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.gis</span></code> to <a class=\"reference internal\" href=\"/pt-br/4.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 para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Like other Django contrib applications, you will <em>only</em> need to add\n<a class=\"reference internal\" href=\"/pt-br/4.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> to <a class=\"reference internal\" href=\"/pt-br/4.1/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> in your settings.\nThis is so that the <code class=\"docutils literal notranslate\"><span class=\"pre\">gis</span></code> templates can be located – if not done, then\nfeatures such as the geographic admin or KML sitemaps will not function properly.</p>\n</section>\n</section>\n<section id=\"troubleshooting\">\n<h2>Solução de Problemas<a class=\"heading-anchor\" href=\"#troubleshooting\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>If you can’t find the solution to your problem here then participate in the\ncommunity!  You can:</p>\n<ul class=\"simple\">\n<li><p>Join the <code class=\"docutils literal notranslate\"><span class=\"pre\">#django-geo</span></code> IRC channel on Libera.Chat. Please be patient and\npolite – while you may not get an immediate response, someone will attempt\nto answer your question as soon as they see it.</p></li>\n<li><p>Ask your question on the <a class=\"reference external\" href=\"https://forum.djangoproject.com/c/internals/geodjango/13\">GeoDjango</a> forum.</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 “GIS”.</p></li>\n</ul>\n<section id=\"library-environment-settings\">\n<span id=\"libsettings\"></span><h3>Library environment settings<a class=\"heading-anchor\" href=\"#library-environment-settings\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>By far, the most common problem when installing GeoDjango is that the\nexternal shared libraries (e.g., for GEOS and GDAL) cannot be located. <a class=\"footnote-reference brackets\" href=\"#id22\" id=\"id5\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>1<span class=\"fn-bracket\">]</span></a>\nTypically, the cause of this problem is that the operating system isn’t aware\nof the directory where the libraries built from source were installed.</p>\n<p>In general, the library path may be set on a per-user basis by setting\nan environment variable, or by configuring the library path for the entire\nsystem.</p>\n<section id=\"ld-library-path-environment-variable\">\n<h4><code class=\"docutils literal notranslate\"><span class=\"pre\">LD_LIBRARY_PATH</span></code> environment variable<a class=\"heading-anchor\" href=\"#ld-library-path-environment-variable\"><span class=\"visually-hidden\">Link para este cabeçalho</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\"><span class=\"pre\">/usr/local/lib</span></code>.  Thus, <code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/lib</span></code> needs\nto be included in the <code class=\"docutils literal notranslate\"><span class=\"pre\">LD_LIBRARY_PATH</span></code> variable.  For example, the user\ncould place the following in their bash profile:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"go\">export LD_LIBRARY_PATH=/usr/local/lib</span>\n</code></pre></div>\n</section>\n<section id=\"setting-system-library-path\">\n<h4>Setting system library path<a class=\"heading-anchor\" href=\"#setting-system-library-path\"><span class=\"visually-hidden\">Link para este cabeçalho</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\"><span class=\"pre\">/etc/ld.so.conf</span></code>, which may include\nadditional paths from files in another directory, such as <code class=\"docutils literal notranslate\"><span class=\"pre\">/etc/ld.so.conf.d</span></code>.\nAs the root user, add the custom library path (like <code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/lib</span></code>) on a\nnew line in <code class=\"docutils literal notranslate\"><span class=\"pre\">ld.so.conf</span></code>.  This is <em>one</em> example of how to do so:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"gp\">$ </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=\"gp\">$ </span>sudo<span class=\"w\"> </span>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\"><span class=\"pre\">crle</span></code> utility.  Run <code class=\"docutils literal notranslate\"><span class=\"pre\">crle</span></code> with no options to see the current configuration\nand use <code class=\"docutils literal notranslate\"><span class=\"pre\">crle</span> <span class=\"pre\">-l</span></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=\"console\"><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=\"gp\"># </span>crle<span class=\"w\"> </span>-l<span class=\"w\"> </span><span class=\"nv\">$OLD_PATH</span>:/usr/local/lib\n</code></pre></div>\n</section>\n<section id=\"install-binutils\">\n<span id=\"binutils\"></span><h4>Install <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code><a class=\"heading-anchor\" href=\"#install-binutils\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>GeoDjango uses the <code class=\"docutils literal notranslate\"><span class=\"pre\">find_library</span></code> function (from the <code class=\"docutils literal notranslate\"><span class=\"pre\">ctypes.util</span></code> Python\nmodule) to discover libraries.  The <code class=\"docutils literal notranslate\"><span class=\"pre\">find_library</span></code> routine uses a program\ncalled <code class=\"docutils literal notranslate\"><span class=\"pre\">objdump</span></code> (part of the <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code> package) to verify a shared\nlibrary on GNU/Linux systems.  Thus, if <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></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 perfectly.</p>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code> package may be installed on Debian and Ubuntu systems using the\nfollowing command:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"gp\">$ </span>sudo<span class=\"w\"> </span>apt-get<span class=\"w\"> </span>install<span class=\"w\"> </span>binutils\n</code></pre></div>\n<p>Similarly, on Red Hat and CentOS systems:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"gp\">$ </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>Platform-specific instructions<a class=\"heading-anchor\" href=\"#platform-specific-instructions\"><span class=\"visually-hidden\">Link para este cabeçalho</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 para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Because of the variety of packaging systems available for macOS, users have\nseveral different options for installing GeoDjango. These options are:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"#postgresapp\"><span class=\"std std-ref\">Postgres.app</span></a> (easiest and recommended)</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=\"/pt-br/4.1/ref/contrib/gis/install/geolibs/#build-from-source\"><span class=\"std std-ref\">Building from source</span></a></p></li>\n</ul>\n<p>This section also includes instructions for installing an upgraded version\nof <a class=\"reference internal\" href=\"#macos-python\"><span class=\"std std-ref\">Python</span></a> from packages provided by the Python Software\nFoundation, however, this is not required.</p>\n<section id=\"python\">\n<span id=\"macos-python\"></span><h4>Python<a class=\"heading-anchor\" href=\"#python\"><span class=\"visually-hidden\">Link para este cabeçalho</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 “pristine” for internal\noperating system use.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Nota</p>\n<p>You will need to modify the <code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> environment variable in your\n<code class=\"docutils literal notranslate\"><span class=\"pre\">.profile</span></code> file so that the new version of Python is used when\n<code class=\"docutils literal notranslate\"><span class=\"pre\">python</span></code> is entered at the command-line:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"go\">export PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$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 para este cabeçalho</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\"><span class=\"pre\">gdal</span></code> and\n<code class=\"docutils literal notranslate\"><span class=\"pre\">libgeoip</span></code> with <a class=\"reference internal\" href=\"#homebrew\"><span class=\"std std-ref\">Homebrew</span></a>.</p>\n<p>After installing Postgres.app, add the following to your <code class=\"docutils literal notranslate\"><span class=\"pre\">.bash_profile</span></code> so\nyou can run the package’s programs from the command-line. Replace <code class=\"docutils literal notranslate\"><span class=\"pre\">X.Y</span></code> with\nthe version of PostgreSQL in the Postgres.app you installed:</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>You can check if the path is set up correctly by typing <code class=\"docutils literal notranslate\"><span class=\"pre\">which</span> <span class=\"pre\">psql</span></code> at a\nterminal prompt.</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 para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference external\" href=\"https://brew.sh/\">Homebrew</a> provides “recipes” for building binaries and packages from source.\nIt provides recipes for the GeoDjango prerequisites on Macintosh computers\nrunning macOS. Because Homebrew still builds the software from source, <a class=\"reference external\" href=\"https://developer.apple.com/xcode/\">Xcode</a>\nis required.</p>\n<p>Summary:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"gp\">$ </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>postgresql\n<span class=\"gp\">$ </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>postgis\n<span class=\"gp\">$ </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>gdal\n<span class=\"gp\">$ </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 para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h5>\n<p><a class=\"reference external\" href=\"https://schwehr.blogspot.com/\">Kurt Schwehr</a> has been gracious enough to create GeoDjango packages for users\nof the <a class=\"reference external\" href=\"https://www.finkproject.org/\">Fink</a> package system. <a class=\"reference external\" href=\"https://pdb.finkproject.org/pdb/browse.php?summary=django-gis\">Different packages are available</a> (starting\nwith <code class=\"docutils literal notranslate\"><span class=\"pre\">django-gis</span></code>), depending on which version of Python you want to use.</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 para este cabeçalho</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>Summary:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"gp\">$ </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>postgresql13-server\n<span class=\"gp\">$ </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>geos\n<span class=\"gp\">$ </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>proj6\n<span class=\"gp\">$ </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>postgis3\n<span class=\"gp\">$ </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>gdal\n<span class=\"gp\">$ </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\">Nota</p>\n<p>You will also have to modify the <code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> in your <code class=\"docutils literal notranslate\"><span class=\"pre\">.profile</span></code> so\nthat the MacPorts programs are accessible from the command-line:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"go\">export PATH=/opt/local/bin:/opt/local/lib/postgresql13/bin</span>\n</code></pre></div>\n<p>In addition, add the <code class=\"docutils literal notranslate\"><span class=\"pre\">DYLD_FALLBACK_LIBRARY_PATH</span></code> setting so that\nthe libraries can be found by Python:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"go\">export DYLD_FALLBACK_LIBRARY_PATH=/opt/local/lib:/opt/local/lib/postgresql13</span>\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 para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Proceed through the following sections sequentially in order to install\nGeoDjango on Windows. In this tutorial we will install 64 bit versions of each\napplication.</p>\n<section id=\"id18\">\n<h4>Python<a class=\"heading-anchor\" href=\"#id18\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Install a 64 bit version of Python. See <a class=\"reference internal\" href=\"/pt-br/4.1/howto/windows/\"><span class=\"doc\">Install Python</span></a>\nfor further information.</p>\n</section>\n<section id=\"postgresql\">\n<h4>PostgreSQL<a class=\"heading-anchor\" href=\"#postgresql\"><span class=\"visually-hidden\">Link para este cabeçalho</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 12.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\">Nota</p>\n<p>The PostgreSQL installer creates a new <code class=\"docutils literal notranslate\"><span class=\"pre\">postgres</span></code> database superuser\nYou will be prompted once to set the password – make sure to remember it!</p>\n</aside>\n<p>When the installer completes, it will ask to “Launch Stack Builder at exit?” –\nkeep this checked, as it is necessary to install <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\">Nota</p>\n<p>If installed successfully, the PostgreSQL server will run in the background\neach time the system as started as a Windows service. A\n<span class=\"menuselection\">PostgreSQL 12</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\"><span class=\"pre\">psql</span></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 para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>From within the Stack Builder (to run outside of the installer,\n<span class=\"menuselection\">Start ‣ PostgreSQL 12 ‣ Application Stack Builder</span>), select\n<span class=\"menuselection\">PostgreSQL 12 (x64) on port 5432</span> from the drop down\nmenu and click next. Expand the\n<span class=\"menuselection\">Categories ‣ Spatial Extensions</span> menu tree and select\n<span class=\"menuselection\">PostGIS X.Y for PostgreSQL 12</span>.</p>\n<p>After clicking next, you will be prompted to confirm the selected package and\n“Download directory”. Click next again, this will download PostGIS and you will\nbe asked to click next to begin the PostGIS installer. Select the default\noptions during install. The install process includes three Yes/No dialog boxes,\nthe default option for all three is “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 para este cabeçalho</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> (64bit), 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; MapServer is also enabled\nby default, but is not required by GeoDjango and may be unchecked safely. After\nclicking next and accepting the license agreements, the packages will be\nautomatically downloaded and installed, after which you may exit the installer.</p>\n</section>\n<section id=\"modify-windows-environment\">\n<h4>Modify Windows environment<a class=\"heading-anchor\" href=\"#modify-windows-environment\"><span class=\"visually-hidden\">Link para este cabeçalho</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\"><span class=\"pre\">Path</span></code>, as well as create <code class=\"docutils literal notranslate\"><span class=\"pre\">GDAL_DATA</span></code>\nand <code class=\"docutils literal notranslate\"><span class=\"pre\">PROJ_LIB</span></code> environment variables.  The following set of commands,\nexecutable with <code class=\"docutils literal notranslate\"><span class=\"pre\">cmd.exe</span></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:\\OSGeo4W64\n<span class=\"k\">set</span> <span class=\"nv\">GDAL_DATA</span><span class=\"p\">=</span><span class=\"nv\">%OSGEO4W_ROOT%</span>\\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\">Nota</p>\n<p>This assumes 64bit version of OSGeo4W is installed. If you have installed\nthe 32bit version you will need to change the first command to\n<code class=\"docutils literal notranslate\"><span class=\"pre\">set</span> <span class=\"pre\">OSGEO4W_ROOT=C:\\OSGeo4W</span></code>.</p>\n</aside>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Nota</p>\n<p>Administrator privileges are required to execute these commands.\nTo do this, run command prompt as administrator and enter the commands\nabove. You need to log out and log back in again for the settings to take\neffect.</p>\n</aside>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Nota</p>\n<p>If you customized the OSGeo4W installation directories, then you will need\nto modify the <code class=\"docutils literal notranslate\"><span class=\"pre\">OSGEO4W_ROOT</span></code> variables accordingly.</p>\n</aside>\n</section>\n<section id=\"install-django-and-set-up-database\">\n<h4>Install Django and set up database<a class=\"heading-anchor\" href=\"#install-django-and-set-up-database\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference internal\" href=\"/pt-br/4.1/topics/install/#installing-official-release\"><span class=\"std std-ref\">install Django</span></a> on your system. It is\nrecommended that you create a <a class=\"reference external\" href=\"https://docs.python.org/3/tutorial/venv.html\" title=\"(em Python v3.14)\"><span class=\"xref std std-doc\">virtual environment</span></a> for each project you create.</p>\n</section>\n<section id=\"psycopg2\">\n<h4>psycopg2<a class=\"heading-anchor\" href=\"#psycopg2\"><span class=\"visually-hidden\">Link para este cabeçalho</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">psycopg2</span></code> Python module provides the interface between Python and the\nPostgreSQL database. <code class=\"docutils literal notranslate\"><span class=\"pre\">psycopg2</span></code> can be installed via pip within your Python\nvirtual environment:</p>\n<div class=\"code-block\" data-language=\"console\"><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=\"go\">...\\&gt; py -m pip install psycopg2</span>\n</code></pre></div>\n<p class=\"rubric\">Notas de rodapé</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 uses the <a class=\"reference external\" href=\"https://docs.python.org/3/library/ctypes.html#ctypes.util.find_library\" title=\"(em Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">find_library()</span></code></a> routine from\n<code class=\"docutils literal notranslate\"><span class=\"pre\">ctypes.util</span></code> to locate shared libraries.</p>\n</aside>\n</aside>\n</section>\n</section>\n</section>","rootId":"geodjango-installation","toc":[{"title":"Visão Geral","anchor":"overview","children":[]},{"title":"Requerimentos","anchor":"requirements","children":[{"title":"Python e Django","anchor":"python-and-django","children":[]},{"title":"Spatial database","anchor":"spatial-database","children":[]}]},{"title":"Instalação","anchor":"installation","children":[{"title":"Bibliotecas Geospatial","anchor":"geospatial-libraries","children":[]},{"title":"Instalação do banco de dados","anchor":"database-installation","children":[]},{"title":"DATABASES configuration","anchor":"databases-configuration","children":[]},{"title":"Add django.contrib.gis to INSTALLED_APPS","anchor":"add-django-contrib-gis-to-installed-apps","children":[]}]},{"title":"Solução de Problemas","anchor":"troubleshooting","children":[{"title":"Library environment settings","anchor":"library-environment-settings","children":[{"title":"LD_LIBRARY_PATH environment variable","anchor":"ld-library-path-environment-variable","children":[]},{"title":"Setting system library path","anchor":"setting-system-library-path","children":[]},{"title":"Install binutils","anchor":"install-binutils","children":[]}]}]},{"title":"Platform-specific instructions","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":"Modify Windows environment","anchor":"modify-windows-environment","children":[]},{"title":"Install Django and set up database","anchor":"install-django-and-set-up-database","children":[]},{"title":"psycopg2","anchor":"psycopg2","children":[]}]}]}],"breadcrumbs":[{"docname":"ref/index","title":"Referência da API","url":"/pt-br/4.1/ref/"},{"docname":"ref/contrib/index","title":"contrib packages","url":"/pt-br/4.1/ref/contrib/"},{"docname":"ref/contrib/gis/index","title":"GeoDjango","url":"/pt-br/4.1/ref/contrib/gis/"}],"prev":{"docname":"ref/contrib/gis/tutorial","title":"GeoDjango Tutorial","url":"/pt-br/4.1/ref/contrib/gis/tutorial/"},"next":{"docname":"ref/contrib/gis/install/geolibs","title":"Installing Geospatial libraries","url":"/pt-br/4.1/ref/contrib/gis/install/geolibs/"},"formats":{"html":"/pt-br/4.1/ref/contrib/gis/install/","markdown":"/pt-br/4.1/ref/contrib/gis/install.md","json":"/pt-br/4.1/ref/contrib/gis/install.json"},"source":"https://github.com/django/django/blob/stable/4.1.x/docs/ref/contrib/gis/install/index.txt","official":"https://docs.djangoproject.com/pt-br/4.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"]}