{"title":"Installation de GeoDjango","version":"5.1","locale":"fr","docname":"ref/contrib/gis/install/index","url":"/fr/5.1/ref/contrib/gis/install/","canonical":"https://djangodocs.dev/fr/5.1/ref/contrib/gis/install/","summary":"Aperçu Lien vers cette rubrique # En général, l’installation de GeoDjango requiert : Python et Django Base de données spatiale Installation des bibliothèques…","html":"<h1>Installation de GeoDjango<a class=\"heading-anchor\" href=\"#geodjango-installation\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h1>\n<section id=\"overview\">\n<h2>Aperçu<a class=\"heading-anchor\" href=\"#overview\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>En général, l’installation de GeoDjango requiert :</p>\n<ol class=\"arabic simple\">\n<li><p><a class=\"reference internal\" href=\"#django\"><span class=\"std std-ref\">Python et Django</span></a></p></li>\n<li><p><a class=\"reference internal\" href=\"#spatial-database\"><span class=\"std std-ref\">Base de données spatiale</span></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/fr/5.1/ref/contrib/gis/install/geolibs/\"><span class=\"doc\">Installation des bibliothèques géospatiales</span></a></p></li>\n</ol>\n<p>Des détails au sujet de chaque exigence et des instructions d’installation sont fournies dans les sections ci-dessous. De plus, des instructions spécifiques à des plates-formes particulières sont disponibles pour :</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\">Utilisation du code source</p>\n<p>Comme GeoDjango tire profit des derniers développements de la technologie logicielle géospatiale libre, des versions récentes des bibliothèques sont nécessaires. Si des paquets binaires ne sont pas disponibles sur votre plate-forme, il peut être nécessaire d’installer à partir des sources. Lors de la compilation des bibliothèques à partir des sources, suivez attentivement les consignes, particulièrement si vous êtes débutant.</p>\n</aside>\n</section>\n<section id=\"requirements\">\n<h2>Exigences<a class=\"heading-anchor\" href=\"#requirements\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"python-and-django\">\n<span id=\"django\"></span><h3>Python et Django<a class=\"heading-anchor\" href=\"#python-and-django\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Comme GeoDjango est inclus dans Django, référez-vous aux <a class=\"reference internal\" href=\"/fr/5.1/topics/install/#installing-official-release\"><span class=\"std std-ref\">instructions d’installation</span></a> de Django pour des détails sur l’installation.</p>\n</section>\n<section id=\"spatial-database\">\n<span id=\"id1\"></span><h3>Base de données spatiale<a class=\"heading-anchor\" href=\"#spatial-database\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>PostgreSQL (avec PostGIS), MySQL, Oracle et SQLite (avec SpatiaLite) sont les bases de données spatiales actuellement prises en charge.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>PostGIS est recommandé, car c’est la base de données spatiale libre la plus mature et riche en fonctionnalités.</p>\n</aside>\n<p>Les bibliothèques géospatiales requises pour une installation de GeoDjango dépendent de la base de données spatiale utilisée. Le tableau ci-après présente les bibliothèques requises, les versions prises en charge et d’éventuelles notes pour les différents moteurs de base de données :</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>Base de données</p></th>\n<th class=\"head\"><p>Bibliothèques requises</p></th>\n<th class=\"head\"><p>Versions prises en charge</p></th>\n<th class=\"head\"><p>Notes</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p>PostgreSQL</p></td>\n<td><p>GEOS, GDAL, PROJ, PostGIS</p></td>\n<td><p>13+</p></td>\n<td><p>Exige 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=\"/fr/5.1/ref/contrib/gis/db-api/#mysql-spatial-limitations\"><span class=\"std std-ref\">Fonctionnalités limitées</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 non pris en charge.</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>Nécessite SpatiaLite 4.3+</p></td>\n</tr>\n</tbody>\n</table>\n</div>\n<p>Voir aussi cette <a class=\"reference external\" href=\"https://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS\">matrice comparative</a> sur le Wiki OSGeo pour des combinaisons possibles entre PostgreSQL/PostGIS/GEOS/GDAL.</p>\n</section>\n</section>\n<section id=\"installation\">\n<h2>Installation<a class=\"heading-anchor\" href=\"#installation\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h2>\n<section id=\"geospatial-libraries\">\n<h3>Bibliothèques géospatiales<a class=\"heading-anchor\" href=\"#geospatial-libraries\"><span class=\"visually-hidden\">Lien vers cette rubrique</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=\"/fr/5.1/ref/contrib/gis/install/geolibs/\">Installation des bibliothèques géospatiales</a></li>\n</ul>\n</div>\n</section>\n<section id=\"database-installation\">\n<h3>Installation de la base de données<a class=\"heading-anchor\" href=\"#database-installation\"><span class=\"visually-hidden\">Lien vers cette rubrique</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=\"/fr/5.1/ref/contrib/gis/install/postgis/\">Installation de PostGIS</a></li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/fr/5.1/ref/contrib/gis/install/spatialite/\">Installation de SpatiaLite</a></li>\n</ul>\n</div>\n</section>\n<section id=\"databases-configuration\">\n<h3>Configuration de <a class=\"reference internal\" href=\"/fr/5.1/ref/settings/#std-setting-DATABASES\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">DATABASES</span></code></a><a class=\"heading-anchor\" href=\"#databases-configuration\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Définissez le réglage <a class=\"reference internal\" href=\"/fr/5.1/ref/settings/#std-setting-DATABASE-ENGINE\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">ENGINE</span></code></a> à l’un des <a class=\"reference internal\" href=\"/fr/5.1/ref/contrib/gis/db-api/#spatial-backends\"><span class=\"std std-ref\">moteurs spatiaux</span></a>.</p>\n</section>\n<section id=\"add-django-contrib-gis-to-installed-apps\">\n<h3>Ajout de <code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.gis</span></code> à <a class=\"reference internal\" href=\"/fr/5.1/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a><a class=\"heading-anchor\" href=\"#add-django-contrib-gis-to-installed-apps\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Comme pour d’autres applications contribuées dans Django, il <em>suffit</em> d’ajouter <a class=\"reference internal\" href=\"/fr/5.1/ref/contrib/gis/#module-django.contrib.gis\" title=\"django.contrib.gis: Geographic Information System (GIS) extensions for Django\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">django.contrib.gis</span></code></a> à <a class=\"reference internal\" href=\"/fr/5.1/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> dans vos réglages. Ceci afin que les gabarits <code class=\"docutils literal notranslate\"><span class=\"pre\">gis</span></code> puissent être découverts ; dans le cas contraire, certaines fonctions comme l’interface d’administration géographique ou les plans de sites KML ne fonctionneraient pas correctement.</p>\n</section>\n</section>\n<section id=\"troubleshooting\">\n<h2>Dépannage<a class=\"heading-anchor\" href=\"#troubleshooting\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Si vous ne trouvez pas de solution à votre problème sur cette page, participez alors à la communauté ! Vous pouvez :</p>\n<ul class=\"simple\">\n<li><p>Poser votre question sur le forum <a class=\"reference external\" href=\"https://forum.djangoproject.com/c/internals/geodjango/13\">GeoDjango</a> (en anglais).</p></li>\n<li><p>Créer un ticket dans le <a class=\"reference external\" href=\"https://code.djangoproject.com/newticket\">trac de Django</a> si vous pensez qu’il y a un bogue. Prenez soin de fournir une description complète du problème, les versions utilisées et indiquez le composant « GIS ».</p></li>\n</ul>\n<section id=\"library-environment-settings\">\n<span id=\"libsettings\"></span><h3>Réglages d’environnement de bibliothèques<a class=\"heading-anchor\" href=\"#library-environment-settings\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Le problème de loin le plus fréquent lors de l’installation de GeoDjango est que les bibliothèques partagées externes (par ex. GEOS et GDAL) ne sont pas trouvées  <a class=\"footnote-reference brackets\" href=\"#id22\" id=\"id5\" role=\"doc-noteref\"><span class=\"fn-bracket\">[</span>1<span class=\"fn-bracket\">]</span></a>. Typiquement, la cause de ce problème est que le système d’exploitation ne connaît pas les répertoires dans lesquels sont installées les bibliothèques compilées à partir de leurs sources.</p>\n<p>En général, le chemin de bibliothèque peut être défini pour chaque utilisateur en définissant une variable d’environnement ou en configurant un chemin de bibliothèque global pour tout le système.</p>\n<section id=\"ld-library-path-environment-variable\">\n<h4>Variable d’environnement <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\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Un utilisateur peut définir cette variable d’environnement pour personnaliser les chemins de bibliothèques qu’ils souhaitent utiliser. Le répertoire de bibliothèques traditionnel pour du logiciel compilé depuis les sources est <code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/lib</span></code>. Il faut donc inclure <code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/lib</span></code> dans la variable <code class=\"docutils literal notranslate\"><span class=\"pre\">LD_LIBRARY_PATH</span></code>. Par exemple, voici ce qu’un utilisateur pourrait ajouter dans son fichier de profil bash :</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"nb\">export</span><span class=\"w\"> </span><span class=\"nv\">LD_LIBRARY_PATH</span><span class=\"o\">=</span>/usr/local/lib\n</code></pre></div>\n</section>\n<section id=\"setting-system-library-path\">\n<h4>Définition du chemin de bibliothèque au niveau système<a class=\"heading-anchor\" href=\"#setting-system-library-path\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Sur les systèmes GNU/Linux, il existe le plus souvent un fichier <code class=\"docutils literal notranslate\"><span class=\"pre\">/etc/ld.so.conf</span></code> qui peut contenir des chemins supplémentaires provenant de fichiers d’un autre répertoire, tel que <code class=\"docutils literal notranslate\"><span class=\"pre\">/etc/ld.so.conf.d</span></code>. En tant qu’utilisateur root, ajoutez le chemin de bibliothèque personnalisé (comme <code class=\"docutils literal notranslate\"><span class=\"pre\">/usr/local/lib</span></code>) sur une nouvelle ligne dans <code class=\"docutils literal notranslate\"><span class=\"pre\">ld.so.conf</span></code>. Ceci est <em>un</em> exemple de la façon dont on peut le faire :</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>Pour les utilisateurs d’OpenSolaris, le chemin des bibliothèques systèmes peut être modifié par l’utilitaire <code class=\"docutils literal notranslate\"><span class=\"pre\">crle</span></code>. Exécutez <code class=\"docutils literal notranslate\"><span class=\"pre\">crle</span></code> sans option pour afficher la configuration actuelle et exécutez <code class=\"docutils literal notranslate\"><span class=\"pre\">crle</span> <span class=\"pre\">-l</span></code> pour définir un nouveau chemin de bibliothèque. Soyez <em>très</em> prudent lors de la modification de chemins de bibliothèques systèmes :</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>Installation de <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code><a class=\"heading-anchor\" href=\"#install-binutils\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>GeoDjango utilise la fonction <code class=\"docutils literal notranslate\"><span class=\"pre\">find_library</span></code> (provenant du module Python <code class=\"docutils literal notranslate\"><span class=\"pre\">ctypes.util</span></code>) pour chercher les bibliothèques. La routine <code class=\"docutils literal notranslate\"><span class=\"pre\">find_library</span></code> utilise un programme nommé <code class=\"docutils literal notranslate\"><span class=\"pre\">objdump</span></code> (faisant partie du paquet <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code>) pour vérifier la présence d’une bibliothèque partagée sur les systèmes GNU/Linux. De ce fait, si <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code> n’est pas installé sur votre système Linux, le module ctypes de Python pourrait ne pas trouver une bibliothèque même si le chemin des bibliothèques est correctement défini et que les bibliothèques géospatiales ont été compilées avec succès.</p>\n<p>Le paquet <code class=\"docutils literal notranslate\"><span class=\"pre\">binutils</span></code> peut être installé sur les systèmes Debian et Ubuntu en utilisant la commande suivante :</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>De même, sur les systèmes Red Hat et CentOS :</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>yum<span class=\"w\"> </span>install<span class=\"w\"> </span>binutils\n</code></pre></div>\n</section>\n</section>\n</section>\n<section id=\"platform-specific-instructions\">\n<h2>Instructions spécifiques à certaines plates-formes<a class=\"heading-anchor\" href=\"#platform-specific-instructions\"><span class=\"visually-hidden\">Lien vers cette rubrique</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\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>En raison de la variété des systèmes d’empaquetage disponibles pour macOS, il existe différentes options pour installer GeoDjango. Ces options sont :</p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"#postgresapp\"><span class=\"std std-ref\">Postgres.app</span></a> (le plus simple et la solution recommandée)</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=\"/fr/5.1/ref/contrib/gis/install/geolibs/#build-from-source\"><span class=\"std std-ref\">Compilation à partir des sources</span></a></p></li>\n</ul>\n<p>Cette section inclut aussi des instructions pour installer une version mise à jour de <a class=\"reference internal\" href=\"#macos-python\"><span class=\"std std-ref\">Python</span></a> à partir de paquets fournis par la fondation Python Software, mais ce n’est pas une obligation.</p>\n<section id=\"python\">\n<span id=\"macos-python\"></span><h4>Python<a class=\"heading-anchor\" href=\"#python\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Même si Python est préinstallé sur macOS, il est possible de le réinstaller avec des <a class=\"reference external\" href=\"https://www.python.org/ftp/python/\">paquets fournis</a> par la fondation Python Software. Un des avantages de ces installeurs est que la version Python propre à macOS et utilisée en interne par le système d’exploitation n’est pas touchée.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>Il sera alors nécessaire de modifier la variable d’environnement <code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> dans votre fichier <code class=\"docutils literal notranslate\"><span class=\"pre\">.profile</span></code> afin que la nouvelle version de Python soit utilisée lorsque vous saisissez <code class=\"docutils literal notranslate\"><span class=\"pre\">python</span></code> dans la ligne de commande :</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\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference external\" href=\"https://postgresapp.com/\">Postgres.app</a> est un serveur PostgreSQL indépendant qui inclut l’extension PostGIS. Il sera aussi nécessaire d’installer <code class=\"docutils literal notranslate\"><span class=\"pre\">gdal</span></code> et <code class=\"docutils literal notranslate\"><span class=\"pre\">libgeoip</span></code> avec <a class=\"reference internal\" href=\"#homebrew\"><span class=\"std std-ref\">Homebrew</span></a>.</p>\n<p>Après avoir installé Postgres.app, ajoutez ce qui suit à votre fichier <code class=\"docutils literal notranslate\"><span class=\"pre\">.bash_profile</span></code> afin de pouvoir exécuter les programmes correspondants à partir de la ligne de commande. Remplacez <code class=\"docutils literal notranslate\"><span class=\"pre\">X.Y</span></code> par la version de PostgreSQL dans le paquet Postgres.app que vous avez installé :</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>Vous pouvez vérifier si le chemin est correctement défini en tapant <code class=\"docutils literal notranslate\"><span class=\"pre\">which</span> <span class=\"pre\">psql</span></code> dans une invite de commande.</p>\n</section>\n<section id=\"homebrew\">\n<span id=\"id9\"></span><h4>Homebrew<a class=\"heading-anchor\" href=\"#homebrew\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference external\" href=\"https://brew.sh/\">Homebrew</a> met à disposition des « recettes » pour la compilation de binaires et de paquets à partir des sources. Il fournit des recettes pour les prérequis de GeoDjango sur les ordinateurs Macintosh tournant sous macOS. Dans la mesure où Homebrew compile les logiciels à partir de leurs sources, <a class=\"reference external\" href=\"https://developer.apple.com/xcode/\">Xcode</a> est indispensable.</p>\n<p>En résumé :</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>$<span class=\"w\"> </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>postgresql\n$<span class=\"w\"> </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>postgis\n$<span class=\"w\"> </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>gdal\n$<span class=\"w\"> </span>brew<span class=\"w\"> </span>install<span class=\"w\"> </span>libgeoip\n</code></pre></div>\n<section id=\"fink\">\n<span id=\"id11\"></span><h5>Fink<a class=\"heading-anchor\" href=\"#fink\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h5>\n<p><a class=\"reference external\" href=\"https://schwehr.blogspot.com/\">Kurt Schwehr</a> a eu la bonté de créer des paquets GeoDjango pour les utilisateurs du système de paquets <a class=\"reference external\" href=\"https://www.finkproject.org/\">Fink</a>. <a class=\"reference external\" href=\"https://pdb.finkproject.org/pdb/browse.php?summary=django-gis\">Différents paquets sont disponibles</a> (commençant par <code class=\"docutils literal notranslate\"><span class=\"pre\">django-gis</span></code>), en fonction de la version de Python que vous souhaitez utiliser.</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\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference external\" href=\"https://www.macports.org/\">MacPorts</a> peut être utilisé pour installer les prérequis de GeoDjango sur les ordinateurs tournant sous macOS. Dans la mesure où MacPorts compile les logiciels à partir de leurs sources, <a class=\"reference external\" href=\"https://developer.apple.com/xcode/\">Xcode</a> est indispensable.</p>\n<p>En résumé :</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code>$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>postgresql13-server\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>geos\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>proj6\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>postgis3\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>gdal\n$<span class=\"w\"> </span>sudo<span class=\"w\"> </span>port<span class=\"w\"> </span>install<span class=\"w\"> </span>libgeoip\n</code></pre></div>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>Il sera aussi nécessaire de modifier la variable d’environnement <code class=\"docutils literal notranslate\"><span class=\"pre\">PATH</span></code> dans votre fichier <code class=\"docutils literal notranslate\"><span class=\"pre\">.profile</span></code> afin que les programmes MacPorts soient accessibles dans la ligne de commande :</p>\n<div class=\"code-block\" data-language=\"shell\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Shell</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Shell code\"><code><span class=\"nb\">export</span><span class=\"w\"> </span><span class=\"nv\">PATH</span><span class=\"o\">=</span>/opt/local/bin:/opt/local/lib/postgresql13/bin\n</code></pre></div>\n<p>De plus, ajoutez le réglage <code class=\"docutils literal notranslate\"><span class=\"pre\">DYLD_FALLBACK_LIBRARY_PATH</span></code> afin que les bibliothèques puissent être trouvées par 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/postgresql13\n</code></pre></div>\n</aside>\n</section>\n</section>\n<section id=\"windows\">\n<span id=\"id17\"></span><h3>Windows<a class=\"heading-anchor\" href=\"#windows\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>Suivez scrupuleusement l’ordre des sections suivantes afin d’installer GeoDjango sur Windows. Dans ce tutoriel, nous installerons les versions 64 bits de chaque application.</p>\n<section id=\"id18\">\n<h4>Python<a class=\"heading-anchor\" href=\"#id18\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Installez une version 64 bits de Python. Voir <a class=\"reference internal\" href=\"/fr/5.1/howto/windows/\"><span class=\"doc\">Installation de Python</span></a> pour plus d’informations.</p>\n</section>\n<section id=\"postgresql\">\n<h4>PostgreSQL<a class=\"heading-anchor\" href=\"#postgresql\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Téléchargez la dernière version de l”<a class=\"reference external\" href=\"https://www.enterprisedb.com/downloads/postgres-postgresql-downloads\">installeur PostgreSQL 15.x</a> à partir du site web <a class=\"reference external\" href=\"https://www.enterprisedb.com\">EnterpriseDB</a>. Puis, lancez cet installeur, suivez les instructions qui apparaissent et conservez les options par défaut, sauf si vous connaissez les conséquences de leur modification.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>L’installeur PostgreSQL crée un nouveau superutilisateur de base de données nommé <code class=\"docutils literal notranslate\"><span class=\"pre\">postgres</span></code>. On vous demandera une seule fois de définir le mot de passe, prenez garde de bien vous en souvenir !</p>\n</aside>\n<p>Lorsque l’installeur a terminé, il demande de lancer Stack Builder en quittant. Laissez cette option cochée, car c’est nécessaire pour installer <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\">Note</p>\n<p>En cas d’installation réussie, le serveur PostgreSQL tourne en arrière-plan à chaque démarrage du système sous forme de service Windows. Un groupe de menu de démarrage <span class=\"menuselection\">PostgreSQL 15</span> sera créé pour contenir des raccourcis pour les programmes Application Stack Builder (ASB) et SQL Shell ; ce dernier lance une commande <code class=\"docutils literal notranslate\"><span class=\"pre\">psql</span></code> dans une fenêtre de commandes.</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\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>À partir du programme Stack Builder (à lancer en dehors de l’installeur, <span class=\"menuselection\">Démarrer ‣ PostgreSQL 15 ‣ Application Stack Builder</span>), choisissez <span class=\"menuselection\">PostgreSQL 15 (x64) on port 5432</span> dans le menu déroulant et cliquez sur Suivant. Ouvrez l’arborescence de menu <span class=\"menuselection\">Categories ‣ Spatial Extensions</span> et choisissez <span class=\"menuselection\">PostGIS X.Y for PostgreSQL 15</span>.</p>\n<p>Après avoir cliqué sur suivant, vous devez confirmer le paquet sélectionné et le « Download directory ». Cliquez une nouvelle fois sur suivant, PostGIS sera téléchargé et vous devrez encore cliquer sur suivant pour lancer l’installeur PostGIS. Choisissez les options par défaut lors de l’installation. Le processus d’installation contient quatre boîtes de dialogue Oui/Non, l’option par défaut étant Non pour les quatre.</p>\n</section>\n<section id=\"osgeo4w\">\n<span id=\"id21\"></span><h4>OSGeo4W<a class=\"heading-anchor\" href=\"#osgeo4w\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>L”<a class=\"reference external\" href=\"https://trac.osgeo.org/osgeo4w/\">installeur OSGeo4W</a> aide à l’installation des bibliothèques PROJ, GDAL et GEOS requises par GeoDjango. Commencez par télécharger l”<a href=\"#id23\"><span class=\"problematic\" id=\"id24\">`installeur OSGeo4W`_</span></a> et exécutez-le. Choisissez <span class=\"menuselection\">Express Web-GIS Install</span> et cliquez sur suivant. Dans la liste de sélection des paquets, contrôlez que GDAL est sélectionné. Si d’autres paquets sont sélectionnés par défaut, ils ne sont pas nécessaires pour GeoDjango et peuvent être désélectionnés sans problème. Après avoir cliqué sur suivant et accepté l’accord de licence, les paquets sont automatiquement téléchargés et installés ; vous pouvez ensuite quitter l’installeur.</p>\n</section>\n<section id=\"modify-windows-environment\">\n<h4>Modification de l’environnement Windows<a class=\"heading-anchor\" href=\"#modify-windows-environment\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Afin de pouvoir utiliser GeoDjango, il est nécessaire d’ajouter les répertoires  OSGeo4W au chemin <code class=\"docutils literal notranslate\"><span class=\"pre\">Path</span></code> du système Windows. Il faut également créer les variables d’environnement <code class=\"docutils literal notranslate\"><span class=\"pre\">GDAL_DATA</span></code> et <code class=\"docutils literal notranslate\"><span class=\"pre\">PROJ_LIB</span></code>. Les commandes ci-après, exécutables avec <code class=\"docutils literal notranslate\"><span class=\"pre\">cmd.exe</span></code> configurent tout cela. Redémarrez votre appareil une fois que tout est terminé afin que les nouvelles variables d’environnement soient reconnues :</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\">Note</p>\n<p>Il est nécessaire de disposer des droits d’administrateur pour exécuter ces commandes. Dans ce but, lancez une invite de commande en mode administrateur et saisissez les commandes ci-dessus. Vous devez vous déconnecter puis vous reconnecter pour que ces réglages s’appliquent réellement.</p>\n</aside>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>Si vous avez personnalisé les répertoires d’installation de OSGeo4W, vous devrez alors aussi modifier de façon cohérente les variables <code class=\"docutils literal notranslate\"><span class=\"pre\">OSGEO4W_ROOT</span></code>.</p>\n</aside>\n</section>\n<section id=\"install-django-and-set-up-database\">\n<h4>Installation de Django et configuration de base de données<a class=\"heading-anchor\" href=\"#install-django-and-set-up-database\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p><a class=\"reference internal\" href=\"/fr/5.1/topics/install/#installing-official-release\"><span class=\"std std-ref\">Installez Django</span></a> sur votre système. Il est recommandé de créer un <a class=\"reference external\" href=\"https://docs.python.org/3/tutorial/venv.html\" title=\"(disponible dans Python v3.14)\"><span class=\"xref std std-doc\">environnement virtuel</span></a> pour chaque projet que vous créez.</p>\n</section>\n<section id=\"psycopg\">\n<h4>psycopg<a class=\"heading-anchor\" href=\"#psycopg\"><span class=\"visually-hidden\">Lien vers cette rubrique</span><span aria-hidden=\"true\">#</span></a></h4>\n<p>Le module Python <code class=\"docutils literal notranslate\"><span class=\"pre\">psycopg</span></code> fournit l’interface entre Python et la base de données PostgreSQL. <code class=\"docutils literal notranslate\"><span class=\"pre\">psycopg</span></code> peut être installé par pip dans votre environnement virtuel Python :</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\">Notes de bas de page</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 utilise la routine <a class=\"reference external\" href=\"https://docs.python.org/3/library/ctypes.html#ctypes.util.find_library\" title=\"(disponible dans Python v3.14)\"><code class=\"xref py py-func docutils literal notranslate\"><span class=\"pre\">find_library()</span></code></a> de <code class=\"docutils literal notranslate\"><span class=\"pre\">ctypes.util</span></code> pour trouver les bibliothèques partagées.</p>\n</aside>\n</aside>\n</section>\n</section>\n</section>","rootId":"geodjango-installation","toc":[{"title":"Aperçu","anchor":"overview","children":[]},{"title":"Exigences","anchor":"requirements","children":[{"title":"Python et Django","anchor":"python-and-django","children":[]},{"title":"Base de données spatiale","anchor":"spatial-database","children":[]}]},{"title":"Installation","anchor":"installation","children":[{"title":"Bibliothèques géospatiales","anchor":"geospatial-libraries","children":[]},{"title":"Installation de la base de données","anchor":"database-installation","children":[]},{"title":"Configuration de DATABASES","anchor":"databases-configuration","children":[]},{"title":"Ajout de django.contrib.gis à INSTALLED_APPS","anchor":"add-django-contrib-gis-to-installed-apps","children":[]}]},{"title":"Dépannage","anchor":"troubleshooting","children":[{"title":"Réglages d’environnement de bibliothèques","anchor":"library-environment-settings","children":[{"title":"Variable d’environnement LD_LIBRARY_PATH","anchor":"ld-library-path-environment-variable","children":[]},{"title":"Définition du chemin de bibliothèque au niveau système","anchor":"setting-system-library-path","children":[]},{"title":"Installation de binutils","anchor":"install-binutils","children":[]}]}]},{"title":"Instructions spécifiques à certaines plates-formes","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":"Modification de l’environnement Windows","anchor":"modify-windows-environment","children":[]},{"title":"Installation de Django et configuration de base de données","anchor":"install-django-and-set-up-database","children":[]},{"title":"psycopg","anchor":"psycopg","children":[]}]}]}],"breadcrumbs":[{"docname":"ref/index","title":"Référence de l’API","url":"/fr/5.1/ref/"},{"docname":"ref/contrib/index","title":"Paquets contrib","url":"/fr/5.1/ref/contrib/"},{"docname":"ref/contrib/gis/index","title":"GeoDjango","url":"/fr/5.1/ref/contrib/gis/"}],"prev":{"docname":"ref/contrib/gis/tutorial","title":"Tutoriel GeoDjango","url":"/fr/5.1/ref/contrib/gis/tutorial/"},"next":{"docname":"ref/contrib/gis/install/geolibs","title":"Installation des bibliothèques géospatiales","url":"/fr/5.1/ref/contrib/gis/install/geolibs/"},"formats":{"html":"/fr/5.1/ref/contrib/gis/install/","markdown":"/fr/5.1/ref/contrib/gis/install.md","json":"/fr/5.1/ref/contrib/gis/install.json"},"source":"https://github.com/django/django/blob/stable/5.1.x/docs/ref/contrib/gis/install/index.txt","official":"https://docs.djangoproject.com/fr/5.1/ref/contrib/gis/install/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","zh-hans","fr","ja","id","it","pt-br","ko","es","el","pl"]}