python - 在 Mac OS X Lion 上安装 GDAL

标签 python osx-lion gdal

我正在尝试使用以下方法在 Mac OS X Lion 上安装 GDAL 1.7.1:

python setup.py build
python setup.py install

得到错误:

running build
running build_py
running build_ext
building 'osgeo._gdal' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -arch i386 -arch x86_64 -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Python/2.7/site-packages/numpy-2.0.0.dev_e2af7b7_20110721-py2.7-macosx-10.7-x86_64.egg/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.7/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.7-intel-2.7/extensions/gdal_wrap.o
unable to execute llvm-gcc-4.2: No such file or directory
error: command 'llvm-gcc-4.2' failed with exit status 1

这是正确的编译器吗?我怎样才能让它工作?

更新:

我通过安装 Xcode 获得了更多信息:

running build
running build_py
running build_ext
building 'osgeo._gdal' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/Library/Python/2.7/site-packages/numpy-2.0.0.dev_e2af7b7_20110721-py2.7-macosx-10.7-x86_64.egg/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.7/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.7-intel-2.7/extensions/gdal_wrap.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
extensions/gdal_wrap.cpp:2813:22: error: cpl_port.h: No such file or directory
extensions/gdal_wrap.cpp:2814:24: error: cpl_string.h: No such file or directory
extensions/gdal_wrap.cpp:2815:27: error: cpl_multiproc.h: No such file or directory
extensions/gdal_wrap.cpp:2817:18: error: gdal.h: No such file or directory
extensions/gdal_wrap.cpp:2818:23: error: gdal_priv.h: No such file or directory
extensions/gdal_wrap.cpp:2819:22: error: gdal_alg.h: No such file or directory
extensions/gdal_wrap.cpp:2820:24: error: gdalwarper.h: No such file or directory
extensions/gdal_wrap.cpp:2837: error: expected initializer before ‘VeryQuietErrorHandler’
extensions/gdal_wrap.cpp:2713: warning: ‘swig_module’ defined but not used
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
extensions/gdal_wrap.cpp:2813:22: error: cpl_port.h: No such file or directory
extensions/gdal_wrap.cpp:2814:24: error: cpl_string.h: No such file or directory
extensions/gdal_wrap.cpp:2815:27: error: cpl_multiproc.h: No such file or directory
extensions/gdal_wrap.cpp:2817:18: error: gdal.h: No such file or directory
extensions/gdal_wrap.cpp:2818:23: error: gdal_priv.h: No such file or directory
extensions/gdal_wrap.cpp:2819:22: error: gdal_alg.h: No such file or directory
extensions/gdal_wrap.cpp:2820:24: error: gdalwarper.h: No such file or directory
extensions/gdal_wrap.cpp:2837: error: expected initializer before ‘VeryQuietErrorHandler’
extensions/gdal_wrap.cpp:2713: warning: ‘swig_module’ defined but not used
lipo: can't open input file: /var/tmp//ccgnLEPX.out (No such file or directory)
error: command 'llvm-gcc-4.2' failed with exit status 1

最佳答案

Homebrew 非常适合我。要使用 Homebrew 安装 GDAL 1.9,你所要做的就是

      brew install gdal

Homebrew 需要 xcode,我认为是命令行工具。可以找到更多信息here

关于python - 在 Mac OS X Lion 上安装 GDAL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6915700/

相关文章:

python - 如何测试通过 git 提取的 python 库的更改?

google-colaboratory - Colab - 使用 GDAL 拆分大 tiff 文件

python pycurl 获取最终 url 重定向

python - 实现渲染到顶点数组,glReadPixels 失败(无效操作)

ios - 如何在 Xcode 4.3 上查看复制到构建文件夹的资源?

macos - 帮助改进我针对 Safari 高内存使用率的个人解决方案,或说明为什么它不好

macos - 如何使用 GDAL 将 jp2000 转换为 geotiff?

c++ - 如何以编程方式为 Qt 中的当前进程设置环境变量?

python - 如何使用 Python 通过 Cloud Dataflow 将 CSV 文件导入 Cloud Bigtable?

ruby - 错误: Rack app won't run -- bundler/setup