Whether you are finding it difficult to install the GDAL library or have been able to install it but do not know how to make it work in Django for your geoDjango app, I would like to share how I was able to successfully get it to work for me. I hope I would not miss any step as it took me days to make it work.
Solution to installing GDAL/PROJ/GEOS in windows 10 for Django/Geodjango
3k Views Asked by james morgan At
1
There are 1 best solutions below
Related Questions in PYTHON
- new thread blocks main thread
- Extracting viewCount & SubscriberCount from YouTube API V3 for a given channel, where channelID does not equal userID
- Display images on Django Template Site
- Difference between list() and dict() with generators
- How can I serialize a numpy array while preserving matrix dimensions?
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Why is my program adding int as string (4+7 = 47)?
- store numpy array in mysql
- how to omit the less frequent words from a dictionary in python?
- Update a text file with ( new words+ \n ) after the words is appended into a list
- python how to write list of lists to file
- Removing URL features from tokens in NLTK
- Optimizing for Social Leaderboards
- Python : Get size of string in bytes
- What is the code of the sorted function?
Related Questions in DJANGO
- Display images on Django Template Site
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Django invalid literal for int() with base 10:
- Removing URL features from tokens in NLTK
- Django Noob URL to from Root Page to sub Page
- Django Admin tables not displaying correctly
- Django with chartkick
- Django urls.py not rendering correct template
- django form errors before submit
- django admin: custom app_index with context
- Display multiple models in one view in Django
- Unexpected NoReverseMatch error when using include() in urls patterns
- Search for a key in django.core.cache
- Django webapp (on an Apache2 server) hangs indefintely when importing nltk in views.py
- Django flush won't load fixtures
Related Questions in GDAL
- Missing projection file in R's rgdal package for geospatial analysis
- max() implemented with basic operators
- gdal_merge on a three band .tif - remove the 'no data' value
- readOGR .gdb with multiple Feature Datasets in R
- GDAL C# Style class
- Error during installation of GDAL with ogr2ogr
- Installing GDAL Python binding in Ubuntu to use as standalone module
- Circular dependency issue - Python
- Calling and executable with arguements and getting its STDOUT more efficiently in a Python Script
- Python GDAL installation by pip fails
- How do I get hundreds of DLL files?
- OGR2OGR with MS SQL on Ubuntu 16.04
- Using gdal_merge.py to merge three jpeg2000 files results in an ImportError: libgeos-3.5.0.so
- Why are my X and Y values always out of range of my raster file size?
- Unable to read from "/vsimem/" using vtkGDALVectorReader
Related Questions in GEODJANGO
- Django and GeoDjango database backend
- heroku type "geometry" does not exist after pg:reset
- Heroku Cedar-14 heroku-geo-buildpack GEOSException
- geometry column contains null values
- GeoDjango Segmentation Fault
- Using GeoJson data format how can we write dynamic query for "properties dictionary fields "?
- How to see app and geodata in django-admin page and which tool use for see map(polygon) in django page?
- Geodjango Exception when importing django.contrib.gis.gdal: OSError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name
- GeoDjango saving Point geometry from form
- GeoDjango: cannot import name GEOSException fixed, now [WinError 126]
- GeoDjango error: 'DatabaseOperations' object has no attribute 'geo_db_type'
- Setting up Django with GeoDjango Support in AWS Beanstalk or EC2 Instance
- django-haystack spatial search requirements?
- GeoDjango wanting coordinated in range [-180 -90, 180 90]?
- How to sort for non-geographical (X, Y, Z) distances using GeoDjango / PostGIS?
Related Questions in OSGEO
- Why are my X and Y values always out of range of my raster file size?
- How to display utf-8 characters like alpha and beta in OpenSceneGraph or osg
- Complete reinstall python, pycharm, qgis
- How do I convert one CRS (Coordinate Reference System) value into another using OSGeo4W Shell?
- GDAL_ARRAY import error
- QGIS cannot find headers file
- ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db when using Pyinstaller
- Issues with WAMP server after installing OSGeo4W
- No module named 'osgeo._gdal_array' - Docker image with Python and GDAL
- Conversion problem: Large TIFF File to XYZ Format
- My Windows machine is unable to install PROJ 4.9.0 through the OSGeo4W program. What should I do?
- GDAL and Fiona conflicting versions but downgrading Fiona leads to a legacy-install-failure error
- Solution to installing GDAL/PROJ/GEOS in windows 10 for Django/Geodjango
- How to check if the environment variable "PROJ_LIB" is defined and how to unset it ? (PyQGIS Standalone Script Executer)
- Converting arcpy based python script to OGR for semi-automated Metadata creation
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
For geoDjango to work it needs some free Geospatial libraries, which it uses in the inbuilt
django.contrib.gisapp and I will be showing you how to install it.Step 1: Downloading osgeo4w
For some reason the hosting website https://trac.osgeo.org/osgeo4w/ download link does not work properly, either it won't work at all in chrome or downloads the 32bit in firefox but seems to work alright in the Edge browser an alternative is to use the QGIS link https://qgis.org/en/site/forusers/download.html. You will get a downloaded file as
osgeo4w-setup.exe.Step 2: Installing it
They say use the Express install which I am sure does not work cause I have tried it at least 30 times and each download cost a little above 500MB. Use the Advance install because that was what worked for me. Click on
Things might change a little in the future so be cautious.
Step 3: Modifying Windows environment
Open command prompt in administrative mode for administrative privileges'. You can then copy and paste these one after the other in the order they appear.
This is for win64 systems as of 2022 as it is the one supported, if you are using win32 make sure you download an 32bit version of OSGeo4W/GDAL the same commands will work.
See django Doc for all the commands above.
After you are done you can check the environment variables to confirm your changes by typing in the windows search box:
Click on the Environment Variables button and in the system variables section scroll and double click on Path. Here you should see your python path and also "C:\OSGeo4W" and "C:\OSGeo4W\bin" if you don't click on New and add it yourself.
When done success click on OK on all open windows go back to your python environment and in the command prompt use pip to install psycopg2 if you will be working with Postgres.
Step 4: Configuring django After getting through successfully when you open cmd and type
gdalinfo --versionyou should see the version of gdal installed, but when your run django (python manage.py check or runserser) you will get this error most of the time depending on the version of gdal you installed and if you do not get an error whilst running django you are good to go and no need to follow the rest of the answer.To solve this go to the system folder holding the OSGeo4W most of the time it will be here C:\OSGeo4W open it and locate and open bin as well. Look inside the
binfolder for the largest file with the namegdal***.dll.The *** number if you have a memory span of less than 60 seconds write that number somewhere and go into your python environment where django is installed and navigate to this path:
and open
libgdal.pyfile with your favorite editor.Scroll down to line 24, in the lib_names list, add the *** number into the list as a string, mine was
304. So it becomes something like thisAlso on line 38 add the version of gdal prefixed with gdal like this
"gdal3.4.2", you will get the version when you typegdalinfo --versionin command prompt.Save file and done, you can now run your Geodjango app with no problem. Good luck.