pip install GDAL导致CentOS上的链接错误

时间:2019-04-22 21:30:06

标签: pip python-3.5 centos7 gdal osgeo

无法在我的操作系统上安装Python GDAL软件包。它需要系统安装,而不是环境中。操作系统是CentOS 7,Python版本是3.5。似乎已成功成功安装gdal:

$ sudo yum install epel-release
$ sudo yum install gdal
$ sudo yum install gdal-devel
$ gdal-config --version
1.11.4

然后设置一些我在其他StackOverflow答案中看到的路径:

export CFLAGS=/usr/include/gdal
export CXXFLAGS=/usr/include/gdal
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal

试图获取GDAL python软件包:

$ python3.5 -m pip download GDAL==1.11
$ tar -xvzf GDAL-1.11.0.tar.gz
$ cd GDAL-1.11.0
$ python3.5 setup.py build_ext --include-dirs=/usr/include/gdal/

得到错误:

   gcc: warning: /usr/include/gdal: linker input file unused because linking not done
    creating build/lib.linux-x86_64-3.5
    creating build/lib.linux-x86_64-3.5/osgeo
    g++ -pthread -shared -L/opt/rh/rh-python35/root/usr/lib64-Wl,-z,relro /usr/include/gdal build/temp.linux-x86_64-3.5/extensions/gdal_wrap.o -L../../.libs -L../../ -L/opt/rh/rh-python35/root/usr/lib64 -L/usr/lib -lpython3.5m -lgdal -o build/lib.linux-x86_64-3.5/osgeo/_gdal.cpython-35m-x86_64-linux-gnu.so
    /usr/include/gdal: file not recognized: Is a directory
    collect2: error: ld returned 1 exit status
    error: command 'g++' failed with exit status 1

    ----------------------------------------
Command "/opt/rh/rh-python35/root/usr/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-uwdol9a1/GDAL/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" build_ext -I/usr/include/gdal install --record /tmp/pip-record-yve20nsu/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-uwdol9a1/GDAL/

是某种类型的链接问题?如何获取GDAL的Python软件包?注意我知道GDAL版本是1.11.4,而py包是1.11.0;没有py包1.11.0。

更新:取消设置环境变量并重做pip安装步骤即可解决问题。

0 个答案:

没有答案