How to make GDAL for Django Projects on Window

date
Jan 24, 2024
summary
How to make GDAL for Django Projects on Window
slug
how-to-make-gdal-for-django-projects-on-window
status
Published
tags
Python
My Work
GIS
Django
type
Post
Created time
Jan 24, 2024 01:43 PM
URL
Recently I’m studying python and django framework. And a problem encountered while working on a project which created by a my collage is use GDAL library in project. I will be easier if running project on linux / mac osx because gdal just need install via some command like `sudo apt-get install -y libgdal-dev gdal-bin
notion image
But will really hard if running project on window. I found pyenv-win to be the right flovar for my purpose, and pyenv-win-env for make isolate environment with virtualenv .

TLDR

Step by step

And now with GDAL we can make it easier with pywin
  • Step 1 : Create a folder for project like geo_project by use command python -m venv venv and active it use .\venv\Script\activate If you use nushell like me, we can use command overlay use .\venv\Scripts\activate.nu
  • Step 2 : Install pipwin use command pip install pipwin. This like we are clone person of me. Hahaa =))
  • Step 3 : Install gdal use simple command pipwin install gdal and that’s it. Then continue install django use pip install django. Make a project use command django-admin startproject geo-project and check that everthing is working by python manage.py runserver
  • Step 4: Install missing dependencies pip install psycopg2
  • Step 5 : Connection with PostgreSQL / PostGIS by config in settings.py in database variables
  • Step 6 : Define the variable for django can found GDAL path. There is config in settings.py
 
Updated: If you like me encounter the problem when connect to postgresql and got the problem with postgis not found. I’m running postgresql like portable and add to Laragon. Please add it to postgresql follow this way :
  • Extract all file content from download zip file and merge to postgresql folder in your window. And that’s all. Good luck
 

© Chien Tran 2021 - 2025