Hi all, in setting up a development environment for Arches 5, I just encountered a new method for installing GDAL on windows that is easier than what I'm used to. In the past, I have used the OSGeo4W installer, or have downloaded and installed GDAL separately. The new way I just found actually installs GDAL directly into the virtual environment so you can set environment variables to point to it there on startup.
2. Install the .whl file into your virtual environment
For me: pip install \path\to\downloaded\GDAL-2.4.1-cp37-cp37m-win_amd64.whl
3. In settings_local.py, add these lines. Note that your environment variables are being modified temporarily when the app is run, so you don't need to change any of the real environment variables on your system. The environment variables are now pointing directly inside your virtual environment, not to any global installation of GDAL, OSGeo4W, etc.
import os
os.environ['GDAL_DATA'] = r"C:\archesproject\ENV\Lib\site-packages\osgeo\data\gdal"
os.environ['PROJ_LIB'] = r"C:\archesproject\ENV\Lib\site-packages\osgeo\data\proj"
os.environ['PATH'] = r"C:\archesproject\ENV\Lib\site-packages\osgeo" + os.environ['PATH']
GDAL_LIBRARY_PATH = r'C:\archesproject\ENV\Lib\site-packages\osgeo\gdal204.dll'
If anyone tries this method, please post here to let me and others know how it goes. Would be nice to have a tried and true better way of dealing with GDAL, especially on systems that may need different versions of it for different application.
Adam
p.s. A more dynamic, less hard-coded refactor of the settings_local lines looks like this:
import os
envpath = os.environ['VIRTUAL_ENV']
os.environ['GDAL_DATA'] = os.path.join(envpath, r"Lib\site-packages\osgeo\data\gdal")
os.environ['PROJ_LIB'] = os.path.join(envpath, r"Lib\site-packages\osgeo\data\proj")
os.environ['PATH'] = os.path.join(envpath, r"Lib\site-packages\osgeo") + os.environ['PATH']
GDAL_LIBRARY_PATH = os.path.join(envpath, r"Lib\site-packages\osgeo\gdal204.dll")