'Django / Ubuntu 20 - How change to a previous version of GDAL
first of all, thanks for your help.
I'm new to django, and I'm developing a site where you have to enter coordinates in some forms and then they should be editable.
So far, so good, I haven't had any problem creating that, however, as I read, in some of the more recent versions, the order in which GDAL reads the coordinates was changed, so the positions appear inverted when reading data from geospatial databases. In other words, the coordinates are entered right (from PgAdmin they look right) but are read wrong when you load them into a leaflet map with Django.
I asked about how to correct this (Link to my previous question) but got no answer and haven't been able to solve it myself. Therefore, the only thing I can think of is to try with previous versions of GDAL, however, I'm not quite sure how to do it. I followed the next steps to install it:
pip3 install gdal
sudo apt-get install gdal-bin libgdal-dev
sudo apt-get install python3-gdal
Thanks in advance
EDIT:
I tried with 2.x.x versions, but i'm getting some errors wtih every version under 3.
When executing pip3 install gdal==2.4.4
, first I get the errors command 'x86_64-linux-gnu-gcc' failed with status 1
and ERROR: Failed building wheel for gdal
. Then it uninstalls GDAL 3.0.4 successfully and after a while it reports another status 1:
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cjqeh4e7/gdal/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cjqeh4e7/gdal/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_71slwxo/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ecolab/.local/include/python3.8/gdal Check the logs for full command output.
2020-06-16T11:34:18,929 Exception information:
2020-06-16T11:34:18,929 Traceback (most recent call last):
2020-06-16T11:34:18,929 File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main
2020-06-16T11:34:18,929 status = self.run(options, args)
2020-06-16T11:34:18,929 File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 421, in run
2020-06-16T11:34:18,929 installed = install_given_reqs(
2020-06-16T11:34:18,929 File "/usr/lib/python3/dist-packages/pip/_internal/req/__init__.py", line 67, in install_given_reqs
2020-06-16T11:34:18,929 requirement.install(
2020-06-16T11:34:18,929 File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 820, in install
2020-06-16T11:34:18,929 install_legacy(
2020-06-16T11:34:18,929 File "/usr/lib/python3/dist-packages/pip/_internal/operations/install/legacy.py", line 70, in install
2020-06-16T11:34:18,929 runner(
2020-06-16T11:34:18,929 File "/usr/lib/python3/dist-packages/pip/_internal/utils/subprocess.py", line 271, in runner
2020-06-16T11:34:18,929 call_subprocess(
2020-06-16T11:34:18,929 File "/usr/lib/python3/dist-packages/pip/_internal/utils/subprocess.py", line 242, in call_subprocess
2020-06-16T11:34:18,929 raise InstallationError(exc_msg)
2020-06-16T11:34:18,929 pip._internal.exceptions.InstallationError: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cjqeh4e7/gdal/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cjqeh4e7/gdal/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_71slwxo/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/ecolab/.local/include/python3.8/gdal Check the logs for full command output.
Solution 1:[1]
Unfortunately, there is (currently) no GDAL packages for focal (20.04) in the ubuntugis PPA https://launchpad.net/~ubuntugis/+archive/ubuntu/ppa
.
The best way might be to build the GDAL 2.2.4 and GEOS 3.8.0 librairies from the sources as explained here: https://docs.djangoproject.com/en/2.2/ref/contrib/gis/install/geolibs/#building-from-source.
You must uninstall the GDAL v3 version if already installed in your OS using sudo apt-get remove gdal-bin gdal-data libgdal26
Then you can do the following:
Install GEOS (bzip2):
cd /tmp/
wget https://download.osgeo.org/geos/geos-3.8.0.tar.bz2
tar xjf geos-3.8.0.tar.bz2
cd geos-3.8.0
./configure
make
sudo make install
Install GDAL (gzip):
cd /tmp/
wget https://download.osgeo.org/gdal/2.2.4/gdal-2.2.4.tar.gz
tar xzf gdal-2.2.4.tar.gz
cd gdal-2.2.4
./configure
make
sudo make install
Run ldconfig:
sudo ldconfig
Solution 2:[2]
Have you tried to install an older version with pip? Something like pip3 install gdal==2.3.3
?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Grant Anderson |
Solution 2 | DanielHefti |