Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Create the "nearbyshops" App

Give Feedback

In this video you will be creating a Django app. You’ve already created the Django project which is the main entry point to your website.

This is the current structure of your web app so far. What you are looking at is considered the Django project portion of your web application.

You can see the utilities are there for configuration and routing, but there are no web pages yet, and no interactivity.

This is where the Django app comes in. A request will arrive at the front door of our Django project. Urls.py will determine the destination view for the particular request and direct it to the appropriate Django app.

00:00 Welcome to video number six in this series on making a location-based web app in Django and GeoDjango. In this video, you will be creating a Django app. You’ve already created the Django project, which is the main entry point to your website.

00:16 This is the current structure of your web app so far. What you are looking at is considered the Django project portion of your web application. You can see the utilities are there for configuration and routing, but there are no web pages yet and no interactivity.

00:31 This is where the Django app comes into play. A request will arrive at the front door of our Django project. urls.py will determine the destination view for the particular request and direct it to the appropriate Django app.

00:47 The app, in turn, may have its own urls.py to do additional routing, or it processes the corresponding view specified in the main urls.py.

00:57 A response is then formed and sent back through the main site.

01:03 With the shops project in place, you will create the nearbyshops app. Your shops project can have multiple apps, but for this tutorial you will only be creating one.

01:15 To create a Django app in a project, use the manage.py utility created by the project script when the project was initiated. At your terminal prompt, type python manage.py startapp nearbyshops.

01:31 Let’s see the effect of the startapp script. Notice a new folder has been created with the name of our app. Inside, there are some additional files. The app was successfully created.

01:43 But there’s one more step. The shops project needs to know about the new app, therefore we need to add it to the INSTALLED_APPS list in settings.py.

01:53 The nearbyshops app is now a component of the shops project—great job! You’ve done a lot of work and you may be curious to see if your website starts.

02:02 Let’s see! To launch your site, use the manage.py utility again. At your terminal prompt type python manage.py runserver.

02:13 Your website should launch on localhost port 8000. Click the loopback URL provided by the runserver output. You should see the default page for a new Django project.

02:25 To stop your site just press Control + C back in your terminal. The next step is to get our model set up and some data into our database. Let’s do that in the next video.

Kevin M on May 12, 2019

I’ve got some issues when trying to create the app. It raised the error (django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried “gdal203”, “gdal202”, “gdal201”, “gdal20”, “gdal111”). Is GDAL installed? If it is, try setting GDAL_LIBR ARY_PATH in your settings. )

but when I set the GDAL_LIBRARY_PATH, it still raised the error. I’m working on Windows

Kevin M on May 13, 2019

Done, I finally could debug it!!! I had to add these: GEOS_LIBRARY_PATH = r’C:\OSGeo4W\bin\geos_c.dll’ GDAL_LIBRARY_PATH = r’C:\OSGeo4W\bin\gdal204.dll’

ciaranraymer on May 13, 2019

I’m using Spyder and have not been able to use any of these commands in the terminal, instead I’ve had to use the command prompt. I’m pretty stuck now on the “python manage.py startapp nearby shops” part, as the cmd prompt just opens the script and doesn’t create a folder - any tips for a Windows user?

Jackie Wilson RP Team on May 13, 2019

Are you running your command prompt as admin? I’m going to find a Windows machine and follow my own instructions. Sounds like I have to include some extra steps for Win users.

Darryl Rich on May 19, 2019

I’m running this on Windows 10 and experiencing the same issues as Kevin.

error (django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried “gdal203”, “gdal202”, “gdal201”, “gdal20”, “gdal111”). Is GDAL installed? If it is, try setting GDAL_LIBR ARY_PATH in your settings. )

Not sure where to make the path changes; in the os environment, the venv, or the django manage itself.

Jackie Wilson RP Team on May 20, 2019

I’m putting together some separate instructions for Windows users. Sorry you’re running into trouble. You could set the path in any of those places, or in the settings.py file. Also, you’ll get this error and similar if you have 32-bit python with a 64-bit gdal installation (or vice versa). I mainly work on a Mac, but can appreciate the majority GIS folks probably work in Windows. I’m currently trying to get a clean setup going on Win 10. I’ll update this tutorial when I have that finished.

Justin Cletus on June 30, 2019

Hi Jackie, I am getting this issue after database connection added in seetings.py file, conn = _connect(dsn, connection_factory=connection_factory, **kwasync) django.db.utils.OperationalError: received invalid response to SSL negotiation: - Is there anything I missed in setup?

Jackie Wilson RP Team on July 2, 2019

Hi Justin, first thing to check would be if you have the right port configured. Postgres will default to 5432 but the would be different if you manually changed it, or if you have multiple instances running.

Harshida Rami on July 7, 2019

Hi Jackie,I am using windows and experiencing error same as above

error (django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried “gdal203”, “gdal202”, “gdal201”, “gdal20”, “gdal111”). Is GDAL installed? If it is, try setting GDAL_LIBR ARY_PATH in your settings. ). not sure where and how add path.

ChrisF on Aug. 24, 2019

I am getting the errors as all the others are getting with this. I have checked my folder for any of these: “gdal203”, “gdal202”, “gdal201”, “gdal20”, “gdal111” But it seems like they are not installed. I have tried as much as I can but can’t get it to work.

Does me using Python 3.7 have anything to do with it? I know you said it is not compatible with QGIS but would that have an effect on this part?

Thanks

hithard on Sept. 22, 2019

same error as most of others getting here

maju1005 on Oct. 5, 2019

Hi Jackie, Do you have any updates on issues with GDAL on Windows machines? I just run into the same problem as rest of Win users.

Do you know whether this issue occurs also on Linux?

Thanks in advance for your help and have a nice day!

arjun0910 on Oct. 10, 2019

I’m using a Mac and facing the issue when I type python manage.py startapp nearbyshops

The error I receive is:- Could not find the GDAL library (tried “gdal”, “GDAL”, “gdal2.3.0”, “gdal2.2.0”, “gdal2.1.0”, “gdal2.0.0”, “gdal1.11.0”). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

Please help me, What should i do

kylebronstein on Nov. 4, 2019

I’m on mac and I was getting that error, now I’m getting an error saying it referenced a directory and can’t find an image. I don’t know what to do.

rupaklama on Nov. 6, 2019

I ran “brew install gdal” on my mac, fixed this issue! The installion takes a while.

natej815 on Nov. 15, 2019

Getting this error. would love to get this fixed asap please!

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (t ried “gdal203”, “gdal202”, “gdal201”, “gdal20”, “gdal111”). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

kal on Nov. 29, 2019

For windows 10 users getting the GDAL not found error I found this specific solution using the link above to stack overflow. I added the block of path logic to the top of the settings.py project file just below the existing import os statement.

if os.name == ‘nt’: import platform OSGEO4W = r”C:\OSGeo4W” if ‘64’ in platform.architecture()[0]: OSGEO4W += “64” assert os.path.isdir(OSGEO4W), “Directory does not exist: ” + OSGEO4W os.environ[‘OSGEO4W_ROOT’] = OSGEO4W os.environ[‘GDAL_DATA’] = OSGEO4W + r”\share\gdal” os.environ[‘PROJ_LIB’] = OSGEO4W + r”\share\proj” os.environ[‘PATH’] = OSGEO4W + r”\bin;” + os.environ[‘PATH’]

Masa on Dec. 3, 2019

I ran into the same issue of django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (t ried “gdal203”, “gdal202”, “gdal201”, “gdal20”, “gdal111”). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

I’m using MacOS 10.1.6 High Sierra. Homebrew installed Python3.7.4. I used pyenv and pipenv to set python 3.6.8 in my virtualenv.

How the django find a gdal installed by GGIS?

After all, I used brew install glad. After it was done, python manage.py startapp was run without error.

jlrv16 on Dec. 19, 2019

I got the same issue (on win10 64 bits) python 3.8 . I have installed OSgeo4W64 on my system. To solve this issue just include the following in the settings.py of your project.

GEOTH_LIBRARY_PATH = 'C:\\OSGeo4W64\\bin' GDAL_LIBRARY_PATH = 'C:\\OSGeo4W64\\bin\\gdal300.dll'

hope it will help hose who like me became mad with it!

Pacifique on Dec. 24, 2019

Hi Jackie, I got the same issue (on win10 64 bits) , I have followed this stack overflow solution stackoverflow.com/questions/49139044/geodjango-on-windows-could-not-find-the-gdal-library-oserror-winerror-12

I have installed OSgeo4W64 on my system. and added this block of code in the settings.py

import os if os.name == ‘nt’: import platform OSGEO4W = r”C:\OSGeo4W” if ‘64’ in platform.architecture()[0]: OSGEO4W += “64” assert os.path.isdir(OSGEO4W), “Directory does not exist: ” + OSGEO4W os.environ[‘OSGEO4W_ROOT’] = OSGEO4W os.environ[‘GDAL_DATA’] = OSGEO4W + r”\share\gdal” os.environ[‘PROJ_LIB’] = OSGEO4W + r”\share\proj” os.environ[‘PATH’] = OSGEO4W + r”\bin;” + os.environ[‘PATH’]

But I now get this error: OSError: [WinError 127] The specified module could not be found

How can I solve this issue ?

travisbrown022 on Jan. 3, 2020

thank you @nosizwe31 your solution worked for me too on Windows.

Rony Efendy on Feb. 29, 2020

Hi, I am stuck here.

I’m using Windows 10 64-bit.

Ricky White RP Team on March 1, 2020

Hi Rony. You’re going to have to be a bit more specific. What’s got you stuck?

bhoo on March 15, 2020

Hi All, Pls. help me resolve this issue , I am using window 8.1 32 bit system and tring to run python manage.py startapp nearbyshops command to create app but getting following error: django.core.exceptions.Improperly Configured: Could not find the GDAL library (tried “gdal204”, “gdal203”, “gdal202”, “gdal201”, “gdal20”). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

Ricky White RP Team on March 16, 2020

Hi indibhopal. Others have had the same issue. Please see the comments above.

dthomas01 on March 16, 2020

Hi everyone, I’m late to the party. Yes, I hit the same wall but all your suggestions helped me get a workaround for me. I’m running Windows 10 Pro (64-bit) on a laptop, Python 3.7 (64-bit), PostgreSQL 64-bit, QGIS 64-bit. At the top of the settings.py file, right beneath the “import os” statement (like earlier posts indicated), I pasted all this stuff. My QGIS had installed OSGeo4 here “C:\Program Files\QGIS 3.12" but it wasn’t the embedded spaces. Even the official Django 3.0 install notes said it needs some OS environment path variables added. Simply pasting the following did the trick, to allow the: python manage.py startapp nearbyshops to run to completion. Time has passed. So Python 3.7 is now supported. Here it is:

GEOS_LIBRARY_PATH = ‘C:\Program Files\QGIS 3.12\bin\geos_c.dll’ GDAL_LIBRARY_PATH = ‘C:\Program Files\QGIS 3.12\bin\gdal300.dll’

if os.name == ‘nt’: # raw str path where QGIS Win 10 installer placed GDAL base. OSGEO4W = r”C:\Program Files\QGIS 3.12” assert os.path.isdir(OSGEO4W), “Directory does not exist: ” + OSGEO4W os.environ[‘OSGEO4W_ROOT’] = OSGEO4W os.environ[‘GDAL_DATA’] = OSGEO4W + r”\share\gdal” os.environ[‘PROJ_LIB’] = OSGEO4W + r”\share\proj” os.environ[‘PATH’] = OSGEO4W + r”\bin;” + os.environ[‘PATH’]

bhoo on March 17, 2020

Hi,Ricky White and dthomas01, I tried as u suggested, my earlier error is gone but getting a new error as :OSError: [WinError 126] The specified module could not be found: would appreciate if anyone could help me to resolve this new problem. thanks in advance.

dthomas01 on March 17, 2020

  1. Since you are using an old Windows 32-bit, I hope you installed all 32-bit versions of the other stuff (PostgreSQL, QGIS, etc). Otherwise, you might get a mismatch.
  2. I’m running QGIS version 3.12, the latest. So that’s why my paths show that number. Do you in fact have a gdal.dll file in your C:\Program Files\QGIS 3.12\bin\ folder? If not then just need to fix your paths. Otherwise, there is one last thing to try.
  3. What I did to see which exact file the libgdal.py was choking on was to look at the very last portion of my Traceback error and notice that the error occurred in this file (C:\Users(myuserid)\Anaconda3\lib\ctypes_init.py) at a line of code within class CDLL() having function “def init” which contained this code block:

    if handle is None: self._handle = _dlopen(self._name, mode) else: self._handle = handle

The error occurred right at the dlopen() call. So I just added my own little print() command to tell me what the input value was for self.name like so:

    if handle is None:
        print("DEBUG> opening CDLL file=", self._name)
        self._handle = _dlopen(self._name, mode)
    else:
        self._handle = handle

Then retried the earlier failed: python manage.py startapp nearbyshops

When it errored again, I look way up top in the console for the first 10 lines of system responses and saw my “DEBUG> opening…” printed the name: gdal300.dll Yours might be different…can’t say. At least, pinpointing which file it cannot find is a step in the right direction.

bhoo on March 18, 2020

Hi dthomas01, Appreciate your efforts,my print output=DEBUG> opening CDLL file=kernel32 , is it something to do with windows 8 32 os? kindly advise further.

Mydhe on April 7, 2020

Thank you jlrv16, You fix helped me with this error: django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (t ried “gdal203”, “gdal202”, “gdal201”, “gdal20”, “gdal111”). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

Addidng the path in my settings.py as below. GEOTH_LIBRARY_PATH = ‘C:\OSGeo4W64\bin’ GDAL_LIBRARY_PATH = ‘C:\OSGeo4W64\bin\gdal300.dll’

But before that, after activating my virtual environment i installed GDAL into it as GDAL might be installed Globally and not inside your virtual environment using this, 1. python -m pip install C:/Users/Dlu2/Downloads/GDAL-3.0.4-cp36-cp36m-win_amd64.whl

Am not sure if this had anything to do with clearing the error but just a step i thought is worth mentioning. Am using windows 10

Bill Sanderson on June 9, 2020

This fix error on my mac Thanks - rupaklama on Nov. 6, 2019

I ran “brew install gdal” on my mac, fixed this issue! The installion takes a while. when creating nearbyshops app

lesgod on June 12, 2020

I spent a lot of hours dealing with this OSError error: [WinError 126]. Are there any other suggestions on how I can get rid of it?

George on June 13, 2020

Hi all, tried the same fix as above and basically am ending with the same os error: OSError: [WinError 126] The specified module could not be found. Could you please let us know if this issue is being approached by the extended team for an resolution?! It’s seems to be an issue for quite a while now(just over a year today…), thanks.

Ricky White RP Team on June 14, 2020

HI lesgod and George. Can you share more information? The full Traceback would be helpful so I can help you debug this code. Thanks

George on June 14, 2020

Hi Ricky, unfortunately i’m in between moving house right now and can’t really use my machine; counting on the others in this group facing the same errors to share that traceback; have you tried to replicate this tut on a Windows machine?!

ankitzin on June 16, 2020

I have macbook air and in this while installing postgis it is getting stuck at downloading in elapsed time 0.00.06. Can any one help why this is happening? i tried this postgis installation so many times on windows so please can any one really help me with setting.py whole structure of file.

mikesult on Aug. 11, 2020

A Mac user who adds another thank you to rupaklama on Nov. 6, 2019 for the suggestion to “brew install gdal”. That resolved the django.core.exceptions.ImproperlyConfigured issue and I was able to complete creation of the nearbyshops app.

thanks

bloydkylen on Aug. 14, 2020

Hello Ricky, In regard to George’s comments, I’m having the same issue. Here is the full trace:

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    django.setup()
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\apps\registry.py", line 112, in populate
    app_config.import_models()
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\apps\config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\bloydkn\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
    class AbstractBaseUser(models.Model):
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\db\models\base.py", line 101, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\db\models\base.py", line 305, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\db\models\options.py", line 203, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\db\utils.py", line 202, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\db\utils.py", line 110, in load_backend
    return import_module('%s.base' % backend_name)
  File "C:\Users\bloydkn\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 6, in <module>
    from .features import DatabaseFeatures
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\db\backends\postgis\features.py", line 1, in <module>
    from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\db\backends\base\features.py", line 3, in <module>
    from django.contrib.gis.db.models import aggregates
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 3, in <module>
    import django.contrib.gis.db.models.functions  # NOQA
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\db\models\functions.py", line 4, in <module>
    from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\db\models\fields.py", line 3, in <module>
    from django.contrib.gis import forms, gdal
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\forms\__init__.py", line 3, in <module>
    from .fields import (  # NOQA
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\forms\fields.py", line 2, in <module>
    from django.contrib.gis.geos import GEOSException, GEOSGeometry
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\geos\__init__.py", line 5, in <module>
    from .collections import (  # NOQA
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\geos\collections.py", line 9, in <module>
    from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\geos\geometry.py", line 8, in <module>
    from django.contrib.gis import gdal
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in <module>
    from django.contrib.gis.gdal.datasource import DataSource
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 39, in <module>
    from django.contrib.gis.gdal.driver import Driver
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\gdal\driver.py", line 5, in <module>
    from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in <module>
    from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
  File "C:\Users\bloydkn\repos\geoshops\myvenv\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 47, in <module>
    lgdal = CDLL(lib_path)
  File "C:\Users\bloydkn\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

bloydkylen on Aug. 14, 2020

UPDATE Ricky and George, This worked for me: stackoverflow.com/a/49159195/57952

Ricky White RP Team on Aug. 14, 2020

Glad you got it working bloydkylen :)

Yvonne Wilmot on Sept. 18, 2020

Hi. I had same problem with the GDAL path error - Am using windows 10, Python 3.8.5. I only inserted the 2 lines following the BASE_DIR line below into settings.py. (NOTE: that my QGIS library is 3.10, not 3.12 as in above comments):

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
GEOS_LIBRARY_PATH = "C:/Program Files/QGIS 3.10/bin/geos_c.dll"
GDAL_LIBRARY_PATH = "C:/Program Files/QGIS 3.10/bin/gdal300.dll"

Don’t know if you actually need the GEOS_LIBRARY_PATH line as the libgdal.py module only looks for the GDAL_LIBRARY_PATH?

There is most likely a better place to insert this path in settings.py as the comment in settings.py reads ‘# build paths inside the project like this: BASE_DIR / ‘subdir’.

But I have no idea where in this module to put it as I’m still quite new to Python. Under TEMPLATES - DIRS or APP_DIRS perhaps (only place I can see paths/dirs specified)?

steliosioannidesrisk on Oct. 13, 2020

Hi Jackie have we found the solution for the windows environment ? thank you stelios

steliosioannidesrisk on Oct. 13, 2020

thanks everyone. UPDATE Ricky, George ET AL, This worked for me: stackoverflow.com/a/49159195/57952 ALSO !!

you need to make sure that you follow the solution as per link but make sure that you put the additional settings.py part at the top of the said file.

import os
if os.name == 'nt':
    import platform
    OSGEO4W = r"C:\OSGeo4W"
    if '64' in platform.architecture()[0]:
        OSGEO4W += "64"
    assert os.path.isdir(OSGEO4W), "Directory does not exist: " + OSGEO4W
    os.environ['OSGEO4W_ROOT'] = OSGEO4W
    os.environ['GDAL_DATA'] = OSGEO4W + r"\share\gdal"
    os.environ['PROJ_LIB'] = OSGEO4W + r"\share\proj"
    os.environ['PATH'] = OSGEO4W + r"\bin;" + os.environ['PATH']

then all commands work! e.g. python manage.py startapp nearbyshops

Become a Member to join the conversation.