--
You received this message because you are subscribed to the Google Groups "geodjango" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geodjango+...@googlegroups.com.
To post to this group, send email to geod...@googlegroups.com.
Visit this group at https://groups.google.com/group/geodjango.
For more options, visit https://groups.google.com/d/optout.
OSGEO4W_ROOT=C:\OSGeo4W64
GDAL_DATA=%OSGEO4W_ROOT%\share\gdal
PROJ_LIB=%OSGEO4W_ROOT%\share\proj
PATH=%PATH%;%PYTHON_ROOT%;%OSGEO4W_ROOT%\bin
Then in the settings.py of your Django project add a line:
GDAL_LIBRARY_PATH = r'<path_to_your-virtual_environment>\Lib\site-packages\osgeo\gdal204.dll'
To view this discussion on the web visit https://groups.google.com/d/msgid/geodjango/9a62cf0f-0967-412f-a02a-1ac2c12e0c2cn%40googlegroups.com.
python -m pip install
GDAL‑3.2.1‑cp38‑cp38‑win_amd64.whl (be sure to run this command from your virtual environment directory containing the python.exe script),
you still need to add 'gdal302' to your lib_names variable, so make sure to try this first.
If this doesn't work then you should try with a different version of GDAL.
Let me know how did it go,
All the best,
Vlado
To view this discussion on the web visit https://groups.google.com/d/msgid/geodjango/46a54eb7-0a1c-4598-be9a-bce7005f2d34n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geodjango/f97e5105-9e2b-4fb5-b4bf-fe58580a78ccn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geodjango/615dd40c-8cdf-4d81-bf07-d899e575aed4n%40googlegroups.com.
Sorry Stathis, but in order to be able to help you I need to have complete overview of your problem.Can you post:- pip freeze of your virtual environment,
- spatial dependencies used by your project (psql into your spatial database and then execute SELECT PostGIS_full_version();)
- values of your system variables: Path, GDAL_DATA and PROJ_LIB
- the exact value of GDAL_LIBRARY_PATH variable from Django settings
- GDAL version in OSGeo4W (run gdalinfo --version from OSGeo4w shell)
GDAL 3.1.4, released 2020/10/20
- and last but not least, send the complete error message, without your explanations.
Good luck,Vlado
To view this discussion on the web visit https://groups.google.com/d/msgid/geodjango/7e4166b7-b3b9-453e-84a5-38e19e28d834n%40googlegroups.com.
>>> import os
>>> os.environ['VIRTUAL_ENV']
from inside your virtual environment "mymap".
When yyou are sure about the path to your virtual environemnt, use this path to install GDAL-2.4.1, if you didn't already.
After this, remove all
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']
os.environ['GDAL_LIBRARY_PATH'] = r"\apps\Python36\Lib\site-packages\osgeo\gdal301.dll"
code from your settings file, and just add:
GDAL_LIBRARY_PATH = r'path_to_your_virtual_environment\Lib\site-packages\osgeo\gdal204.dll'
where the "path_to_your_virtual_environment" part is what was returned by
>>> import os
>>> os.environ['VIRTUAL_ENV']
command you executed earlier.
So, regarding the OSGEO4W, you just need to use its "share" folder with paths to gdal and proj folders, where you will at the end copy the missing filed from PG gdal-data to C:\OSGeo4W64\share\gdal (I think you've already done this part).
Remove all other references to OSGeo4W from your system variables and your code.
If you folow all these steps, there should be no problems with your application, and your app will also know where to find Rtree module.
Send us info of what you've done.
All the best, Vlado
To view this discussion on the web visit https://groups.google.com/d/msgid/geodjango/ddd9386e-80c6-4056-a927-e259242e9617n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geodjango/5a7b445b-a21d-4581-928f-040a16b91036n%40googlegroups.com.
Hi Stathis,Everyone new to python (or new to anything) has troubles in the beginning, so don't worry.When it comes to paths and environments its quite common cause of getting stuck when starting with Python and I would recommend some of the great online tutorials to help you move on with this. My personal favorite is Corey Schafer, and I think you would benefit from at least these two basic videos about paths and environments:
After you've done this, you should have better understanding about paths and environments. If you don't, go check other Corey's video that cover more basic stuff, including python installation, working in the command line etc. t helped a lot of people to get started.Regarding your environmental variables, you still don't do exactly what I told you. It is essential to exactly replicate each step to be sure it will work. Otherwise, any little difference could mean that your code will not work as it should.
1. Done
~~~~~~~~~~~~~Delete the following environmental variables:
GDAL_DRIVER_PATH: C:\Users\sangelrd\AppData\Local\Programs\Python\Python36\LibGDAL_LIBRARY_PATH: C:\OSGeo4W64\share\proj; C:\OSGeo4W64\share\gdal; C:\OSGeo4W64\bin\gdal204.dll;C:\Users\sangelrd\AppData\Local\Programs\Python\Python36\Lib\site-packages\django\contrib\gis\gdal;C:\Users\sangelrd\envs\mymap\lib\site-packagesGEOS_LIBRARY_PATH: C:\OSGeo4W64\bin\geos_c.dll
~~~~~~~~~~~~~~~~~~2. Done
~~~~~~~~~~~~~~~~~~~~~~~~Modify variable GDAL_DATA from:
GDAL_DATA: C:\OSGeo4W64\share\gdal;C:\Users\sangelrd\Envs\mymap\Lib\site-packages\osgeo;C:\Users\sangelrd\Envs\mymap\Lib\site-packagestoGDAL_DATA: C:\OSGeo4W64\share\gdal
~~~~~~~~~~~~~~~~~~~~~~~~3. Done
~~~~~~~~~~~~~~~~~~~~~~~~Add variable PROJ_LIB as:PROJ_LIB: C:\OSGeo4W64\share\proj~~~~~~~~~~~~~~~~~~~~~~~4.~~~~~~~~~~~~~~~~~The next thing that is really important is if you installed all of the packages you pip freezed into the virtual environment. From what you showed, i.ePip freeze
C:\Users\sangelrd\projects\mymap>pip freezeyou are just in the folder of your project, but you are showing packages from global environment.If you were in virtual environment the command prompt would look like this:(mymap) C:\Users\sangelrd\projects\mymap>pip freeze
Also, I see virtual environment packages which you would normally install globally and not inside your virtual env.On the other hand maybe you were in the virtual environment, but just forgot to copy the "(mymap)" part. But knowing this is crucial and we need to get it straight, so if you did create virtual environment "mymap" you should activate it with "workon mymap" command (if you are using virtualenvwrapper ) and then pip freeze. If you dont's see the packages installed, then firstly you need to pip install them from inside "mymap" environment (not just the folder). Inside your virtual environment you would like to inastall packages you would use with your project only, so probably Django, GDAL and Rtree.After you are done and clear with the installation of your virtual env, you should save the dependencies inside requirements.txt file for future use (you can easily find videos about this on youtube).
~~~~~~~~~~~~~~~5. Done
~~~~~~~~~~~~~~~~~~~The next thing is that your variable GDAL_LIBRARY_PATH = r'C:\Users\sangelrd\AppData\Local\Programs\Python\Python36\Lib\site-packages\osgeo\gdal204.dll' frpm your settings file is not good.Here you need to point to "gdal.dll" file inside osgeo folder of your virtual environment. So it needs to look like this:
GDAL_LIBRARY_PATH = r' C:\Users\sangelrd\Envs\mymap\Lib\site-packages\osgeo\gdal204.dll' - Added in the settings fileIf you can not find the folder 'C:\Users\sangelrd\Envs\mymap\Lib\site-packages\osgeo', that means you didn't install GDAL inside your virtual environment - Folder is there
but make sure that you add this just in the settings file, and not in your windows environmental variables.~~~~~~~~~~~~~~~~~
6. Already exists
~~~~~~~~~~~~~~~~~
Also the location of "libgdal.py" file is in your virtual environment:C:\Users\sangelrd\Envs\mymap\Lib\site-packages\django\contrib\gis\gdal\libgdal.pyso go there to add 'gdal204' in lib_names variable if it isn't already there.If you can not find the folder 'C:\Users\sangelrd\Envs\mymap\Lib\site-packages\django' it means you didn't install Django inside your virtual environment.~~~~~~~~~~~~~~~~~When you do everything exactly as I told you, and there is still an error, post it immediately. It will make it easier for me to help you, if you don't start to make changes on your own trying to figure out the solution.All the best,Vlado
- got error Is sphinx installed? If not, try 'sudo easy_install sphinx'."
--
You received this message because you are subscribed to the Google Groups "geodjango" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geodjango+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geodjango/48d3d41b-01d3-43d2-a825-e0575c9c3ca6n%40googlegroups.com.