0

When running paver setup attempting to configure Geonode (Windows 10-64bit, Python 39), I get a raise of django being improperly configured. The computer suggests that if I have installed GDAL successfully then I should try setting GDAL_LIBRARY_PATH in my settings. I have successfully installed gdal via pip install GDAL-3.3.1-cp39-cp39-win_amd64.whl.

The settings for the geonode project are as follows (C:\Users\amell\Documents\geonode\geonode):

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']

I then added the below code to the above and still get the same issue:

GDAL_LIBRARY_PATH = r'C:\OSGeo4W64\bin\gdal301.dll'

I have in addition checked the lib names to see if the GDAL version I installed (331) is listed (C:\Users\amell\Documents\geonode_env\Lib\site-packages\django\contrib\gis\gdal\libgdal). Strangely, the .dll in C:\OSGeo4W64\bin is 301 and not 331 (others suggested renaming this which failed), though I installed 331 via pip using the .whl file. I am currently not sure what the problem is, I tried possible solutions suggested by those with the same issue and they do not seem to work for my case. Perhaps I am missing something.

1 Answer 1

0

I have found the following to work for Windows:

Run Python to check if your Python is 32 or 64 bit.
Install corresponding OSGeo4W (32 or 64 bit) into C:\OSGeo4W or C:\OSGeo4W64:
Note: Select Express Web-GIS Install and click next.
In the ‘Select Packages’ list, ensure that GDAL is selected; MapServer and Apache are also enabled by default, may be unchecked safely.
Make sure the following is included in your 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']

Run python manage.py check to verify geodjango is working correctly.

1
  • will this run in production or only locally?
    – Cary H
    Commented Apr 25 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.