Django / Ubuntu 20 - 如何更改为以前版本的 GDAL
Django / Ubuntu 20 - How change to a previous version of GDAL
首先,感谢您的帮助。
我是 django 的新手,我正在开发一个网站,您必须在其中以某些形式输入坐标,然后它们应该是可编辑的。
到目前为止,一切顺利,我在创建它时没有遇到任何问题,但是,正如我所读,在一些较新的版本中,GDAL 读取坐标的顺序发生了变化,因此位置出现从地理空间数据库读取数据时反转。换句话说,坐标输入正确(从 PgAdmin 看来它们是正确的)但是当您使用 Django 将它们加载到传单地图时读取错误。
我询问了如何更正此问题 (),但没有得到任何答复,而且我自己也无法解决。因此,我唯一能想到的就是尝试使用以前版本的 GDAL,但是,我不太确定该怎么做。我按照以下步骤安装它:
pip3 install gdal
sudo apt-get install gdal-bin libgdal-dev
sudo apt-get install python3-gdal
提前致谢
编辑:
我尝试使用 2.x.x 个版本,但我在每个低于 3 的版本中都遇到了一些错误。
执行pip3 install gdal==2.4.4
时,首先得到错误command 'x86_64-linux-gnu-gcc' failed with status 1
和ERROR: Failed building wheel for gdal
。然后它成功卸载 GDAL 3.0.4 并在一段时间后报告另一个状态 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.
您是否尝试过使用 pip 安装旧版本?像 pip3 install gdal==2.3.3
这样的东西?
不幸的是,在 ubuntugis PPA https://launchpad.net/~ubuntugis/+archive/ubuntu/ppa
.
中(当前)没有用于焦点 (20.04) 的 GDAL 包
最好的方法可能是从此处解释的来源构建 GDAL 2.2.4 和 GEOS 3.8.0 库:https://docs.djangoproject.com/en/2.2/ref/contrib/gis/install/geolibs/#building-from-source.
如果已使用 sudo apt-get remove gdal-bin gdal-data libgdal26
安装在 OS 中,则必须卸载 GDAL v3 版本
那么您可以进行以下操作:
安装 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
安装 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
运行 ldconfig:
sudo ldconfig
首先,感谢您的帮助。
我是 django 的新手,我正在开发一个网站,您必须在其中以某些形式输入坐标,然后它们应该是可编辑的。
到目前为止,一切顺利,我在创建它时没有遇到任何问题,但是,正如我所读,在一些较新的版本中,GDAL 读取坐标的顺序发生了变化,因此位置出现从地理空间数据库读取数据时反转。换句话说,坐标输入正确(从 PgAdmin 看来它们是正确的)但是当您使用 Django 将它们加载到传单地图时读取错误。
我询问了如何更正此问题 (
pip3 install gdal
sudo apt-get install gdal-bin libgdal-dev
sudo apt-get install python3-gdal
提前致谢
编辑:
我尝试使用 2.x.x 个版本,但我在每个低于 3 的版本中都遇到了一些错误。
执行pip3 install gdal==2.4.4
时,首先得到错误command 'x86_64-linux-gnu-gcc' failed with status 1
和ERROR: Failed building wheel for gdal
。然后它成功卸载 GDAL 3.0.4 并在一段时间后报告另一个状态 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.
您是否尝试过使用 pip 安装旧版本?像 pip3 install gdal==2.3.3
这样的东西?
不幸的是,在 ubuntugis PPA https://launchpad.net/~ubuntugis/+archive/ubuntu/ppa
.
最好的方法可能是从此处解释的来源构建 GDAL 2.2.4 和 GEOS 3.8.0 库:https://docs.djangoproject.com/en/2.2/ref/contrib/gis/install/geolibs/#building-from-source.
如果已使用 sudo apt-get remove gdal-bin gdal-data libgdal26
那么您可以进行以下操作:
安装 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
安装 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
运行 ldconfig:
sudo ldconfig