Reputation: 94
I am working on a geodjango project on windows-10. I have been following the tutorial and the installation guide from the geodjango documentation. I have installed all required packages and executed the bat script.
Python version: Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:13:57) [MSC v.1916 64 bit (AMD64)]
OSGEO version: GDAL 2.4.1, released 2019/03/15
Initially I had to reconfigure my virtual environment to have a 64-bit python version matching that of the OSGEOW4 application.
I've tried the solutions answered for questions 1 and 2.
Those solutions include:
Setting the environment variables before at the beginning of the settings.py of the django project
Defining the GDAL_LIBRARY_PATH
Adding the gdal version to the django\contrib\gis\gdal\libgdal.py
I have not yet tried the alternative of installing the gdal from a binary file. I do not understand why I would not be able to configure with the OSGEO application.
The error present in the command prompt when executing python manage.py check
is:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
[...]
OSError: [WinError 126] The specified module could not be found
Seems like it is an issue that many encounter.
A concise yet complete answer would be greatly appreciated.
Thanks for the help.
Upvotes: 1
Views: 791
Reputation: 162
The easiest way I've found is:
settings.py
this code (change name of virtualenv if need):
OSGEO_VENV = Path(__file__).parents[1] / 'venv/Lib/site-packages/osgeo/'
GEOS_LIBRARY_PATH = str(OSGEO_VENV / 'geos_c.dll')
GDAL_LIBRARY_PATH = str(OSGEO_VENV / 'gdal204.dll')
os.environ["PATH"] += os.pathsep + str(OSGEO_VENV)```
if previously installed OSGeo, make sure to clean path variables.
Upvotes: 2
Reputation: 94
I ended up downloading the binary GDAL file from this link. The version that worked for my Python version was GDAL-2.4.1-cp37-cp37m-win32.
Some key points if you are stumbling upon the same issue:
Make sure the python version in your virtual environment is the same bit size as the gdal version
to enable execution of .bat scripts you must change the Set-ExecutionPolicy variable
cd .../your-venv/
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Scripts/Activate.ps1
pip install C:\...\GDAL-2.4.1-cp37-cp37m-win32.whl
Hope this helps.
Upvotes: 2