我正在尝试在GD2上将GDAL与Python 3一起安装在AWS EC2 Amazon2计算机(RHEL7)上。 按照此页面上的说明进行操作:Install GDAL on Python 2.7 on a Amazon Linux virtual server我设法使它适用于python 2.7(“从osgeo导入gdal”有效)。
但是,我需要它才能用于安装在计算机上的python3。我试图相应地调整说明,并获得了以下命令集:
sudo yum-config-manager --enable epel
sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel gdal-devel gdal-python python3-devel
sudo yum -y update
cd /tmp
curl -L http://download.osgeo.org/gdal/2.4.0/gdal-2.4.0.tar.gz | tar zxf -
cd gdal-2.4.0/
./configure --prefix=/usr/local --with-python
sudo make -j4
sudo make install
python3 -m pip install numpy --user
sudo -H pip3 install --upgrade pip
CPLUS_INCLUDE_PATH=/usr/include/gdal
C_INCLUDE_PATH=/usr/include/gdal
sudo python3 -m easy_install GDAL -d /usr/lib/python3.7/site-packages --include-dirs=/usr/include/gdal
当我运行最后一条命令时,安装会尝试运行,但失败:
"error: command 'gcc' failed with exit status 1".
在此之前有很多错误,例如:
/usr/local/include/cpl_vsi_error.h:58:24: error: ‘CPL_FORMAT_STRING’ has not been declared
CPL_FORMAT_STRING(const char *fmt), ... )
^~~~~~~~~~~~~~~~~
In file included from extensions/gdal_wrap.cpp:3173:0:
从我收集到的信息来看,gcc找不到GDAL标头,但是它是在命令中指定的,并且我还执行了上面的包含命令:
CPLUS_INCLUDE_PATH=/usr/include/gdal
C_INCLUDE_PATH=/usr/include/gdal
任何想法都会有所帮助!