No problem Lindsey. I just did some more testing and it seems like you can pare down those settings lines. I was suspicious because I realized that PATH line is actually incorrect, and it needs a ";" in it, like this:
os.environ['PATH'] = os.path.join(envpath, r"Lib\site-packages\osgeo")* + ';' + *os.environ['PATH'] Also, everything checks out even after I remove the GDAL_DATA and PROJ_LIB lines. Adam On Wed, Mar 11, 2020 at 4:20 PM Lindsey Gant <[email protected]> wrote: > 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 > <https://groups.google.com/d/msgid/archesproject/63666f24-8e7e-4ad2-a17c-bcc6c73953c5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -- 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/CAGYBTatkCtfcSsB_4wp04Ld7-bRpBPgRdLoQ7mZMXzgchkvVKQ%40mail.gmail.com.
