main__.gdal_config_error: [Errno 2] No such file or directory: ‘gdal-config (gdal源码安装)

  • 装python3.6版本的gdal库,如果通过pip3安装,会报“main.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config”这样的错误

  • gdal下载网址:http://download.osgeo.org/gdal

  • pip安装报错

$ pip install gdal
self.finalize_options()
      File "/tmp/pip-install-x4uercw8/gdal/setup.py", line 311, in finalize_options
        self.gdaldir = self.get_gdal_config('prefix')
      File "/tmp/pip-install-x4uercw8/gdal/setup.py", line 255, in get_gdal_config
        return fetch_config(option)
      File "/tmp/pip-install-x4uercw8/gdal/setup.py", line 154, in fetch_config
        raise gdal_config_error(e)
    __main__.gdal_config_error: [Errno 2] No such file or directory: 'gdal-config': 'gdal-config'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

  • 源码安装GDAL
$ wget http://download.osgeo.org/gdal/3.0.1/gdal-3.0.1.tar.gz

$ tar -xf gdal-3.0.1.tar.gz

$ cd gdal-3.0.1

$ ./configure --prefix=/home/share/wli/software/gdal/3.0.1

checking whether g++ supports C++11 features by default... no
checking whether g++ supports C++11 features with -std=c++11... no
checking whether g++ supports C++11 features with -std=c++0x... no
checking whether g++ supports C++11 features with +std=c++11... no
checking whether g++ supports C++11 features with -h std=c++11... no
configure: error: *** A compiler with support for C++11 language features is required.
(base) [wli@esg-dn1 gdal-3.0.1]$ which gcc
gcc is /usr/bin/gcc
(base) [wli@esg-dn1 gdal-3.0.1]$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
$ export PATH=/opt/gcc/8.3.0/bin/:$PATH
$ export LD_LIBRARY_PATH=/opt/gcc/8.3.0/lib64/:$LD_LIBRARY_PATH
$ gcc --version
gcc (GCC) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#############重新安装
$ ./configure --prefix=/home/share/wli/software/gdal/3.0.1
using ICONV_CPP_CONST=""
checking for PROJ >= 6 library... checking for proj_create_from_wkt in -lproj... no
checking for proj_create_from_wkt in -lproj... no
checking for internal_proj_create_from_wkt in -lproj... no
checking for internal_proj_create_from_wkt in -lproj... no
checking for internal_proj_create_from_wkt in -linternalproj... no
checking for internal_proj_create_from_wkt in -linternalproj... (cached) no
configure: error: PROJ 6 symbols not found

  • 报错configure: error: PROJ 6 symbols not found

  • 重新安装proj

  • 安装proj

$ wget https://github.com/OSGeo/PROJ/releases/download/6.2.0/proj-6.2.0.tar.gz
$ tar -xf proj-6.2.0.tar.gz
$ cd proj-6.2.0
$ ./configure --prefix=/home/share/wli/software/proj/6.2.0
checking for SQLITE3... configure: error: Package requirements (sqlite3 >= 3.7) were not met:

Requested 'sqlite3 >= 3.7' but version of SQLite is 3.6.20

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables SQLITE3_CFLAGS
and SQLITE3_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
$ export PKG_CONFIG_PATH=/home/share/wli/software/anaconda3c/lib/pkgconfig/:$PKG_CONFIG_PATH
$ ./configure --prefix=/home/share/wli/software/proj/6.2.0
$ make
$ make install
  • 生产变量重新测试安装
  • 重新安装gdal
$ ./configure --prefix=/home/share/wli/software/gdal/2.2.3
$ make
$ make install
  • 生产gdal环境变量
$ export PATH=/home/share/wli/software/gdal/2.2.3/bin/:$PATH
$ export LD_LIBRARY_PATH=/home/share/wli/software/gdal/2.2.3/lib/:$LD_LIBRARY_PATH
$ gdalinfo --help
  • 安装python版的gdal
cd /gdal-2.2.3/swig/python/
python setup.py build
python setup.py install

  • import gdal 会报:No module named _gdal
  • 生成指定变量 (gdal位置 显示安装结束前 Installed  /home/.../.egg
export PYTHONPATH=/home/share/wli/software/anaconda3c/lib/python3.7/site-packages/GDAL-2.2.2-py3.7-linux-x86_64.egg/osgeo/:$PYTHONPATH
  • 最后import gdal 测试
$ python
Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 21:52:21) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gdal
>>> 

作者:August________
链接:https://www.jianshu.com/p/b68057e25e85
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

错误"error: [Errno 2] No such file or directory"是指在读取或写入文件时,系统找不到指定的文件或目录。这个错误可以出现在不同的情况下,例如在使用Python读取文件或图片时、在安装gdal库时、或者在执行其他操作时。 引用中的错误是在使用Python读取文件或图片时出现的。系统报错信息中指出文件或目录不存在。这可能是由于文件或目录路径错误导致的,即指定的文件或目录不存在于指定的路径中。 引用中的错误是在安装gdal库时出现的。错误信息中指出找不到gdal-config文件或目录。这可能是由于gdal库的安装过程中缺少了相关依赖文件或者路径配置错误导致的。 引用中的错误是在执行Python脚本时出现的。错误信息中指出指定的文件不存在。这可能是由于指定的文件路径错误或者文件确实不存在导致的。 综上所述,"error: [Errno 2] No such file or directory"错误通常是由于指定的文件或目录路径错误、缺少依赖文件或者安装配置错误等原因导致的。要解决这个错误,可以检查指定的文件路径是否正确,确保文件或目录存在于指定路径中,并且检查相关依赖文件的配置是否正确。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [IOError: [Errno 2] No such file or directory的解决方法](https://blog.csdn.net/JohinieLi/article/details/70855058)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [main__.gdal_config_error: [Errno 2] No such file or directory: ‘gdal-config (gdal源码安装)](https://blog.csdn.net/dou3516/article/details/111875619)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值