6

从终端(Mac OS X Mavericks)运行后sudo pip3.4 install gdal,我收到一条错误消息,指出'col_port.h'找不到文件并显示以下错误:(command '/user/bin/clang/ failed with exit status 1完整消息如下)。

我有 gdal 1.11(从 kingchaos.com 下载的完整框架版本)和最新版本的 Xcode 命令行工具-Apple LLVM 5.1 版(clang-503.0.40)(基于 LLVM 3.4svn)


这是我在运行sudo pip3.4 install gdal命令后得到的错误:

/usr/bin/clang -fno-strict-aliasing -Werror=declaration-after-statement -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -I/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.11/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.6-intel-3.4/extensions/gdal_wrap.o
extensions/gdal_wrap.cpp:2230:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
                    res = SWIG_AddCast(res);
                    ~~~ ^              ~~~
extensions/gdal_wrap.cpp:2233:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
                    res = SWIG_AddCast(res);
                    ~~~ ^              ~~~
extensions/gdal_wrap.cpp:2535:22: warning: unused variable 'swig_empty_runtime_method_table' [-Wunused-variable]
  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
                     ^
extensions/gdal_wrap.cpp:2855:10: fatal error: 'cpl_port.h' file not found
#include "cpl_port.h"
         ^

3 warnings and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
4

2 回答 2

4

解决方案是使用homebrew,然后运行pip3.4

brew install GDAL

并且,一旦安装,

pip3.4 install gdal
于 2014-06-11T04:12:08.370 回答
0

今天遇到了这个问题。使用 brew 安装了 GDAL,但使用 pip3 失败。解决方案是确保您尝试使用 pip 安装的版本与 homebrew 安装的版本相同。

所以首先使用自制软件安装 gdal

brew install gdal

您应该能够在安装过程中看到正在安装的版本。如果您已经安装了 gdal,则可以使用以下命令检查版本:

brew info gdal

对我来说,这表明为我安装的 gdal brew 版本是:2.4.4 所以你可以使用 pip 安装正确的版本

pip3 install gdal==2.4.4

这终于对我有用。

于 2020-05-12T12:49:23.017 回答