{"title":"Installation av GeoDjango","version":"6.0","locale":"sv","docname":"ref/contrib/gis/install/index","url":"/sv/6.0/ref/contrib/gis/install/","canonical":"https://djangodocs.dev/sv/6.0/ref/contrib/gis/install/","summary":"Översikt Link to this heading # I allmänhet kräver installationen av GeoDjango: Python och Django spatial_databas Geospatiala bibliotek Detaljer för varje krav och…","html":"<h1>Installation av 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>Översikt<a class=\"heading-anchor\" href=\"#overview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>I allmänhet kräver installationen av GeoDjango:</p>\n<ol class=\"arabic simple\">\n<li><p><a class=\"reference internal\" href=\"#django\"><span class=\"std std-ref\">Python och Django</span></a></p></li>\n<li><p><span class=\"xref std std-ref\">spatial_databas</span></p></li>\n<li><p><a class=\"reference internal\" href=\"/sv/6.0/ref/contrib/gis/install/geolibs/#geolibs-list\"><span class=\"std std-ref\">Geospatiala bibliotek</span></a></p></li>\n</ol>\n<p>Detaljer för varje krav och installationsanvisningar finns i avsnitten nedan. Dessutom finns plattformsspecifika instruktioner tillgängliga för:</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><span class=\"xref std std-ref\">fönster</span></p></li>\n</ul>\n<aside class=\"admonition-use-the-source admonition\">\n<p class=\"admonition-title\">Använd källan</p>\n<p>Eftersom GeoDjango utnyttjar det senaste inom geospatial mjukvaruteknik med öppen källkod, krävs det aktuella versioner av biblioteken. Om binära paket inte är tillgängliga för din plattform kan installation från källkod krävas. När du kompilerar biblioteken från källkod, följ anvisningarna noga, särskilt om du är nybörjare.</p>\n</aside>\n</section>\n<section id=\"requirements\">\n<h2>Krav<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 och 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>Eftersom GeoDjango ingår i Django hänvisar vi till Djangos <a class=\"reference internal\" href=\"/sv/6.0/topics/install/#installing-official-release\"><span class=\"std std-ref\">installationsinstruktioner</span></a> för mer information om hur du installerar.</p>\n</section>\n<section id=\"spatial-database\">\n<span id=\"id1\"></span><h3>Spatial databas<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 (med PostGIS), MySQL, Oracle och SQLite (med SpatiaLite) är de spatiala databaser som för närvarande stöds.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Observera</p>\n<p>PostGIS rekommenderas eftersom det är den mest utvecklade och funktionsrika spatiala databasen med öppen källkod.</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>Databas</p></th>\n<th class=\"head\"><p>Krav på bibliotek</p></th>\n<th class=\"head\"><p>Versioner som stöds</p></th>\n<th class=\"head\"><p>Anteckningar</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>Kräver 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=\"/sv/6.0/ref/contrib/gis/db-api/#mysql-spatial-limitations\"><span class=\"std std-ref\">Begränsad funktionalitet</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 stöds inte.</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>Kräver SpatiaLite 4.3+</p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Se även <a href=\"#id23\"><span class=\"problematic\" id=\"id24\">`den här jämförelsematrisen`__</span></a> på OSGeo Wiki för PostgreSQL / PostGIS /GEOS / GDAL möjliga kombinationer.</p>\n</section>\n</section>\n<section id=\"installation\">\n<h2>Installation<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>Geospatiala bibliotek<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=\"/sv/6.0/ref/contrib/gis/install/geolibs/\">Installera geospatiala bibliotek</a></li>\n</ul>\n</div>\n</section>\n<section id=\"database-installation\">\n<h3>Installation av databas<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=\"/sv/6.0/ref/contrib/gis/install/postgis/\">Installera PostGIS</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/sv/6.0/ref/contrib/gis/install/spatialite/\">Installera SpatiaLite</a></li>\n</ul>\n</div>\n</section>\n<section id=\"databases-configuration\">\n<h3><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DATABASER</span></code> konfiguration<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>Ange inställningen <a class=\"reference internal\" href=\"/sv/6.0/ref/settings/#std-setting-DATABASE-ENGINE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ENGINE</span></code></a> till en av <a class=\"reference internal\" href=\"/sv/6.0/ref/contrib/gis/db-api/#spatial-backends\"><span class=\"std std-ref\">spatial backends</span></a>.</p>\n</section>\n<section id=\"add-django-contrib-gis-to-installed-apps\">\n<h3>Lägg till <code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.gis</span></code> i <a class=\"reference internal\" href=\"/sv/6.0/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>Precis som andra Django Contrib-applikationer behöver du <em>bara</em> lägga till <a class=\"reference internal\" href=\"/sv/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\"><span class=\"pre\">django.contrib.gis</span></code></a> till <a class=\"reference internal\" href=\"/sv/6.0/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> i dina inställningar. Detta är så att <code class=\"docutils literal notranslate\"><span class=\"pre\">gis</span></code>-mallarna kan lokaliseras - om det inte görs kommer funktioner som den geografiska administratören eller KML-webbplatskartor inte att fungera korrekt.</p>\n</section>\n</section>\n<section id=\"troubleshooting\">\n<h2>Felsökning<a class=\"heading-anchor\" href=\"#troubleshooting\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Om du inte hittar lösningen på ditt problem här kan du delta i gemenskapen!  Detta kan du göra:</p>\n<ul class=\"simple\">\n<li><p>Ställ din fråga på forumet <a href=\"#id23\"><span class=\"problematic\" id=\"id25\">`GeoDjango`__</span></a>.</p></li>\n<li><p>File a ticket on the <a href=\"#id23\"><span class=\"problematic\" id=\"id26\">`Django trac`__</span></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>Inställningar för biblioteksmiljö<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>Det överlägset vanligaste problemet vid installation av GeoDjango är att de externa delade biblioteken (t.ex. för GEOS och GDAL) inte kan hittas. [Orsaken till detta problem är vanligtvis att operativsystemet inte känner till den katalog där biblioteken som byggts från källan installerades.</p>\n<p>I allmänhet kan bibliotekssökvägen ställas in för varje användare genom att ange en miljövariabel eller genom att konfigurera bibliotekssökvägen för hela systemet.</p>\n<section id=\"ld-library-path-environment-variable\">\n<h4>miljövariabeln <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>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=\"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>Ställa in sökväg för systembibliotek<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\"><span class=\"pre\">/etc/ld.so.conf</span></code>, which\nmay include additional paths from files in another directory, such as\n<code class=\"docutils literal notranslate\"><span class=\"pre\">/etc/ld.so.conf.d</span></code>. As the root user, add the custom library path (like\n<code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/lib</span></code>) on a new line in <code class=\"docutils literal notranslate\"><span class=\"pre\">ld.so.conf</span></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>$<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>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=\"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>Installera <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 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\nperfectly.</p>\n<p>Paketet <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code> kan installeras på Debian- och Ubuntu-system med följande kommando:</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>På samma sätt på Red Hat- och CentOS-system:</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>Plattformsspecifika instruktioner<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>På grund av de olika paketeringssystemen som finns tillgängliga för macOS har användarna flera olika alternativ för att installera GeoDjango. Dessa alternativ är:</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"#postgresapp\"><span class=\"std std-ref\">Postgres.app</span></a> (enklast och rekommenderas)</p></li>\n<li><p><a class=\"reference internal\" href=\"#homebrew\"><span class=\"std std-ref\">Hemmabryggare</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><span class=\"xref std std-ref\">bygga_från_källa</span></p></li>\n</ul>\n<p>Detta avsnitt innehåller även instruktioner för att installera en uppgraderad version av <a class=\"reference internal\" href=\"#macos-python\"><span class=\"std std-ref\">Python</span></a> från paket som tillhandahålls av Python Software Foundation, men detta är inte nödvändigt.</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 href=\"#id23\"><span class=\"problematic\" id=\"id27\">`framework\ninstallers`__</span></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\">Observera</p>\n<p>Du måste ändra miljövariabeln <code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> i filen <code class=\"docutils literal notranslate\"><span class=\"pre\">.profile</span></code> så att den nya versionen av Python används när <code class=\"docutils literal notranslate\"><span class=\"pre\">python</span></code> skrivs in på kommandoraden:</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> 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>\nwith <a class=\"reference internal\" href=\"#homebrew\"><span class=\"std std-ref\">Hemmabryggare</span></a>.</p>\n<p>När du har installerat Postgres.app lägger du till följande i din <code class=\"docutils literal notranslate\"><span class=\"pre\">.bash_profile</span></code> så att du kan köra paketets program från kommandoraden. Ersätt <code class=\"docutils literal notranslate\"><span class=\"pre\">X.Y</span></code> med versionen av PostgreSQL i Postgres.app som du installerade:</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>Du kan kontrollera om sökvägen är korrekt inställd genom att skriva <code class=\"docutils literal notranslate\"><span class=\"pre\">which</span> <span class=\"pre\">psql</span></code> i en terminalprompt.</p>\n</section>\n<section id=\"homebrew\">\n<span id=\"id9\"></span><h4>Hemmabryggare<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 href=\"#id23\"><span class=\"problematic\" id=\"id28\">`Homebrew`__</span></a> tillhandahåller ”recept” för att bygga binära filer och paket från källan. Det ger recept för GeoDjango-förutsättningarna på Macintosh-datorer som kör macOS. Eftersom Homebrew fortfarande bygger programvaran från källan krävs <a class=\"reference external\" href=\"https://developer.apple.com/xcode/\">Xcode</a>.</p>\n<p>Sammanfattning:</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</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 href=\"#id23\"><span class=\"problematic\" id=\"id29\">`Kurt Schwehr`__</span></a> har varit snäll nog att skapa GeoDjango-paket för användare av <a href=\"#id23\"><span class=\"problematic\" id=\"id30\">`Fink`__</span></a>-paketsystemet. olika paket finns tillgängliga (börjar med <code class=\"docutils literal notranslate\"><span class=\"pre\">django-gis</span></code>), beroende på vilken version av Python du vill använda.</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 href=\"#id23\"><span class=\"problematic\" id=\"id31\">`MacPorts`__</span></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>Sammanfattning:</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>postgresql14-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</code></pre></div>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Observera</p>\n<p>Du måste också ändra <code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> i din <code class=\"docutils literal notranslate\"><span class=\"pre\">.profile</span></code> så att MacPorts-programmen är tillgängliga från kommandoraden:</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/postgresql14/bin\n</code></pre></div>\n<p>Dessutom ska du lägga till inställningen <code class=\"docutils literal notranslate\"><span class=\"pre\">DYLD_FALLBACK_LIBRARY_PATH</span></code> så att biblioteken kan hittas av Python:</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/postgresql14\n</code></pre></div>\n</aside>\n</section>\n</section>\n<section id=\"windows\">\n<span id=\"id17\"></span><h3>Fönster<a class=\"heading-anchor\" href=\"#windows\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Fortsätt genom följande avsnitt i tur och ordning för att installera GeoDjango på Windows. I denna handledning kommer vi att installera 64-bitarsversioner av varje applikation.</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>Installera en 64-bitarsversion av Python. Se <a class=\"reference internal\" href=\"/sv/6.0/howto/windows/\"><span class=\"doc\">Installera Python</span></a> för ytterligare information.</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 href=\"#id23\"><span class=\"problematic\" id=\"id32\">`PostgreSQL 15.x installer`__</span></a> from the\n<a href=\"#id23\"><span class=\"problematic\" id=\"id33\">`EnterpriseDB`__</span></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\">Observera</p>\n<p>PostgreSQL-installationsprogrammet skapar en ny <code class=\"docutils literal notranslate\"><span class=\"pre\">postgres</span></code> databas superanvändare Du kommer att uppmanas en gång att ställa in lösenordet - se till att komma ihåg det!</p>\n</aside>\n<p>När installationsprogrammet är klart kommer det att fråga om ”Launch Stack Builder at exit?” – håll detta markerat, eftersom det är nödvändigt att installera <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\">Observera</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\"><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 to this heading</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Från Stack Builder (för att köra utanför installationsprogrammet, <span class=\"menuselection\">Start ‣ PostgreSQL 15 ‣ Application Stack Builder</span>), välj <span class=\"menuselection\">PostgreSQL 15 (x64) på port 5432</span> från rullgardinsmenyn och klicka på nästa. Expandera <span class=\"menuselection\">Categories ‣ Spatial Extensions</span> menyträd och välj <span class=\"menuselection\">PostGIS X.Y for PostgreSQL 15</span>.</p>\n<p>När du har klickat på nästa uppmanas du att bekräfta det valda paketet och ”Download directory”. Klicka på nästa igen, detta kommer att ladda ner PostGIS och du kommer att bli ombedd att klicka på nästa för att starta PostGIS-installationsprogrammet. Välj standardalternativ under installationen. Installationsprocessen innehåller fyra Ja/Nej-dialogrutor, standardalternativet för alla fyra är ”Nej”.</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>Ändra Windows-miljön<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\"><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:\\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\">Observera</p>\n<p>Administratörsbehörighet krävs för att utföra dessa kommandon. För att göra detta kör du kommandotolken som administratör och anger kommandona ovan. Du måste logga ut och logga in igen för att inställningarna ska börja gälla.</p>\n</aside>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Observera</p>\n<p>Om du har anpassat OSGeo4W:s installationskataloger måste du ändra variablerna <code class=\"docutils literal notranslate\"><span class=\"pre\">OSGEO4W_ROOT</span></code> i enlighet med detta.</p>\n</aside>\n</section>\n<section id=\"install-django-and-set-up-database\">\n<h4>Installera Django och konfigurera databasen<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><a class=\"reference internal\" href=\"/sv/6.0/topics/install/#installing-official-release\"><span class=\"std std-ref\">Installera Django</span></a> på ditt system. Det rekommenderas att du skapar en <a class=\"reference external\" href=\"https://docs.python.org/3/tutorial/venv.html\" title=\"(in Python v3.14)\"><span class=\"xref std std-doc\">virtuell miljö</span></a> för varje projekt du skapar.</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-modulen `` psycopg`` tillhandahåller gränssnittet mellan Python och PostgreSQL-databasen. <code class=\"docutils literal notranslate\"><span class=\"pre\">psycopg</span></code> kan installeras via pip inom din virtuella Python-miljö:</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\">Fotnoter</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 använder rutinen <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> från <code class=\"docutils literal notranslate\"><span class=\"pre\">ctypes.util</span></code> för att hitta delade bibliotek.</p>\n</aside>\n</aside>\n</section>\n</section>\n</section>","rootId":"geodjango-installation","toc":[{"title":"Översikt","anchor":"overview","children":[]},{"title":"Krav","anchor":"requirements","children":[{"title":"Python och Django","anchor":"python-and-django","children":[]},{"title":"Spatial databas","anchor":"spatial-database","children":[]}]},{"title":"Installation","anchor":"installation","children":[{"title":"Geospatiala bibliotek","anchor":"geospatial-libraries","children":[]},{"title":"Installation av databas","anchor":"database-installation","children":[]},{"title":"DATABASER konfiguration","anchor":"databases-configuration","children":[]},{"title":"Lägg till django.contrib.gis i INSTALLED_APPS","anchor":"add-django-contrib-gis-to-installed-apps","children":[]}]},{"title":"Felsökning","anchor":"troubleshooting","children":[{"title":"Inställningar för biblioteksmiljö","anchor":"library-environment-settings","children":[{"title":"miljövariabeln LD_LIBRARY_PATH","anchor":"ld-library-path-environment-variable","children":[]},{"title":"Ställa in sökväg för systembibliotek","anchor":"setting-system-library-path","children":[]},{"title":"Installera binutils","anchor":"install-binutils","children":[]}]}]},{"title":"Plattformsspecifika instruktioner","anchor":"platform-specific-instructions","children":[{"title":"macOS","anchor":"macos","children":[{"title":"Python","anchor":"python","children":[]},{"title":"Postgres.app","anchor":"postgres-app","children":[]},{"title":"Hemmabryggare","anchor":"homebrew","children":[{"title":"Fink","anchor":"fink","children":[]}]},{"title":"MacPorts","anchor":"macports","children":[]}]},{"title":"Fönster","anchor":"windows","children":[{"title":"Python","anchor":"id18","children":[]},{"title":"PostgreSQL","anchor":"postgresql","children":[]},{"title":"PostGIS","anchor":"postgis","children":[]},{"title":"OSGeo4W","anchor":"osgeo4w","children":[]},{"title":"Ändra Windows-miljön","anchor":"modify-windows-environment","children":[]},{"title":"Installera Django och konfigurera databasen","anchor":"install-django-and-set-up-database","children":[]},{"title":"psycopg","anchor":"psycopg","children":[]}]}]}],"breadcrumbs":[{"docname":"ref/index","title":"API-referens","url":"/sv/6.0/ref/"},{"docname":"ref/contrib/index","title":"contrib paket","url":"/sv/6.0/ref/contrib/"},{"docname":"ref/contrib/gis/index","title":"GeoDjango","url":"/sv/6.0/ref/contrib/gis/"}],"prev":{"docname":"ref/contrib/gis/tutorial","title":"GeoDjango handledning","url":"/sv/6.0/ref/contrib/gis/tutorial/"},"next":{"docname":"ref/contrib/gis/install/geolibs","title":"Installera geospatiala bibliotek","url":"/sv/6.0/ref/contrib/gis/install/geolibs/"},"formats":{"html":"/sv/6.0/ref/contrib/gis/install/","markdown":"/sv/6.0/ref/contrib/gis/install.md","json":"/sv/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/sv/6.0/ref/contrib/gis/install/","inVersions":["6.1","6.0","5.2"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}