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

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.

Comments & Discussion

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.

Become a Member to join the conversation.