Course: Make a Location-Based Web App With Django and GeoDjango
Jackie Wilson 02:3931 Comments
Sep 02, 2017 GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Could not find the GDAL library #37. Closed sangel10 opened this issue Sep 2, 2017 5 comments Closed. The findlibrary routine uses a program called objdump (part of the binutils package) to verify a shared library on GNU/Linux systems. Thus, if binutils is not installed on your Linux system then Python’s ctypes may not be able to find your library even if your library path is set correctly and geospatial libraries were built perfectly. 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 GDALLIBRARYPATH in your settings. I’m using MacOS 10.1.6. By far, the most common problem when installing GeoDjango is that the external shared libraries (e.g., for GEOS and GDAL) cannot be located. Typically, the cause of this problem is that the operating system isn’t aware of the directory where the libraries built from source were installed.
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.
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_LIBRARY_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:OSGeo4Wbingeos_c.dll’GDAL_LIBRARY_PATH = r’C:OSGeo4Wbingdal204.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 WilsonRP 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 WilsonRP 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 WilsonRP 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
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!
nosizwe31 on Oct. 7, 2019
Hi maju1005
found solution from this link :stackoverflow.com/questions/49139044/geodjango-on-windows-could-not-find-the-gdal-library-oserror-winerror-12
arjun0910 on Oct. 10, 2019
I’m using a Mac and facing the issue when I typepython 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 (tried “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 platformOSGEO4W = r”C:OSGeo4W”if ‘64’ in platform.architecture()[0]:OSGEO4W += “64”assert os.path.isdir(OSGEO4W), “Directory does not exist: ” + OSGEO4Wos.environ[‘OSGEO4W_ROOT’] = OSGEO4Wos.environ[‘GDAL_DATA’] = OSGEO4W + r”sharegdal”os.environ[‘PROJ_LIB’] = OSGEO4W + r”shareproj”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:OSGeo4W64bin'GDAL_LIBRARY_PATH = 'C:OSGeo4W64bingdal300.dll'
hope it will help hose who like me became mad with it!
Go to folder mac library. (Lion / Mountain Lion and above)Most users won't need to get into this important folder, and it was Apple's idea to hide the folder, to prevent novice users from accidentally trashing important docs. The user library's location is here: Macintosh HD Users YourUserName LibraryOnly one problem The User Library is hidden From view in the latest versions of the OS. Rating 3.10 (21 Votes)In this Tip's N Tricks article, I want to point out a very important tip for getting around one of Apple's more peculiar security precautions in Mac OS X Lion and Mountain Lion. We'll cover a few different methods to easily access this hidden folder.The User Library is home to many 'under the hood' files and folders that correspond to the various Apps and system processes in your computer. By default, the User Library folder is hidden in Mac OS 10.7 and above.
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 osif os.name ‘nt’:import platformOSGEO4W = r”C:OSGeo4W”if ‘64’ in platform.architecture()[0]:OSGEO4W += “64”assert os.path.isdir(OSGEO4W), “Directory does not exist: ” + OSGEO4Wos.environ[‘OSGEO4W_ROOT’] = OSGEO4Wos.environ[‘GDAL_DATA’] = OSGEO4W + r”sharegdal”os.environ[‘PROJ_LIB’] = OSGEO4W + r”shareproj”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
Ricky WhiteRP 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 WhiteRP Team on March 16, 2020Mac photos library doesn't show up in alien skin folders.
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 FilesQGIS 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 nearbyshopsto run to completion. Time has passed. So Python 3.7 is now supported. Here it is:
GEOS_LIBRARY_PATH = ‘C:Program FilesQGIS 3.12bingeos_c.dll’GDAL_LIBRARY_PATH = ‘C:Program FilesQGIS 3.12bingdal300.dll’
if os.name ‘nt’:# raw str path where QGIS Win 10 installer placed GDAL base.OSGEO4W = r”C:Program FilesQGIS 3.12”assert os.path.isdir(OSGEO4W), “Directory does not exist: ” + OSGEO4Wos.environ[‘OSGEO4W_ROOT’] = OSGEO4Wos.environ[‘GDAL_DATA’] = OSGEO4W + r”sharegdal”os.environ[‘PROJ_LIB’] = OSGEO4W + r”shareproj”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
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)Anaconda3libctypes_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:
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.dllYours 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:OSGeo4W64bin’GDAL_LIBRARY_PATH = ‘C:OSGeo4W64bingdal300.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