Python27ソフトウェアコレクションにgdal pythonパッケージをインストールする

Python27ソフトウェアコレクションにgdal pythonパッケージをインストールする

Centos 6.6仮想マシンがありますPython 2.7 SCL。 gdalとgdal-develをインストールしました。

sclを起動しsudo scl enable python27 bashて実行するとpip install gdal失敗します。

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/opt/rh/python27/root/usr/include/python2.7 -I. -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o

extensions/gdal_wrap.cpp:2855:22: error: cpl_port.h: No such file or directory

extensions/gdal_wrap.cpp:2856:24: error: cpl_string.h: No such file or directory

extensions/gdal_wrap.cpp:2857:27: error: cpl_multiproc.h: No such file or directory

extensions/gdal_wrap.cpp:2858:22: error: cpl_http.h: No such file or directory

extensions/gdal_wrap.cpp:2860:18: error: gdal.h: No such file or directory

extensions/gdal_wrap.cpp:2861:23: error: gdal_priv.h: No such file or directory

extensions/gdal_wrap.cpp:2862:22: error: gdal_alg.h: No such file or directory

extensions/gdal_wrap.cpp:2863:24: error: gdalwarper.h: No such file or directory

extensions/gdal_wrap.cpp:4870:22: error: gdalgrid.h: No such file or directory

extensions/gdal_wrap.cpp:2880: error: ‘CPLErrorHandler’ does not name a type

extensions/gdal_wrap.cpp:2883: error: expected initializer before ‘PythonBindingErrorHandler’

extensions/gdal_wrap.cpp:2755: warning: ‘swig_module’ defined but not used

error: command 'gcc' failed with exit status 1

/opt/rh/python27/root/usr/include/ から gdal を取得するか、 pip に gcc を /usr/include/ として指定させる正しい方法は何ですか?

ベストアンサー1

修正して仮想環境で動作するようにしました。この方法

2つの質問があります。まず、gdalモジュールバージョン1.9.1を排他的に使用する必要がありました。 1.10.0と1.11.0は、Redhatに付属のコアgdalライブラリバージョン1.9.2では動作しません。次に、-I/usr/include/gdal を gcc に渡す必要があります。順序は次のとおりです。

# you might need to do a sudo -s if your virtualenv is owned by root.
scl enable python27 bash
cd $VIRTUENV_ROOT
source bin/activate
pip install --no-install gdal==1.9.1
cd build/gdal
python setup.py build_ext \
  --gdal-config=/usr/bin/gdal-config \
  --include-dirs=/usr/include/gdal/
python setup.py install

仮想環境は必ずしも必要ではありませんが、グローバルPythonビルドフォルダがどこにあるかわかりません。

おすすめ記事