Thanks, Adam!! As someone who has struggled with GDAL, this suggestion is 
very welcome and I would love to hear how it works out for people.



On Wednesday, March 11, 2020 at 1:40:43 PM UTC-7, Adam Cox wrote:
>
> 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.
>
> 1. Download the Windows binary for your appropriate system architecture 
> (64- or 32-bit) from the Christoph Gohlke site: 
> https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
>
> I used version 2.4.1, which seems to be ok so far, even though Django 2.2 
> docs say GDAL 2.3 is the highest supported version: 
> https://docs.djangoproject.com/en/2.2/ref/contrib/gis/install/geolibs/. 
> From the Gohlke site you can get an older version too.
>
> 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' 
>
>
> For reference, here is the stack exchange question where I got this 
> solution: 
> https://gis.stackexchange.com/questions/330418/geodjango-cant-find-gdal
>
> 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")
>

-- 
-- To post, send email to [email protected]. To unsubscribe, send 
email to [email protected]. For more information, 
visit https://groups.google.com/d/forum/archesproject?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Arches Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/archesproject/63666f24-8e7e-4ad2-a17c-bcc6c73953c5%40googlegroups.com.

Reply via email to