无法使用pip在python 3中安装GDAL(clang失败,退出状态为1)

无法使用pip在python 3中安装GDAL(clang失败,退出状态为1),clang,gdal,python-3.4,Clang,Gdal,Python 3.4,从终端(Mac OS X Mavericks)运行sudo pip3.4 install gdal后,我获得一条错误消息,指出未找到'col_port.h'文件,并显示以下错误:命令'/user/bin/clang/退出状态为1失败(完整消息如下) 我有gdal 1.11(从kingchaos.com下载的完整框架版本)和最新版本的Xcode命令行工具——Apple LLVM版本5.1(clang-503.0.40)(基于LLVM 3.4svn) 以下是运行sudo pip3.4 instal

从终端(Mac OS X Mavericks)运行
sudo pip3.4 install gdal
后,我获得一条错误消息,指出未找到
'col_port.h'
文件,并显示以下错误:
命令'/user/bin/clang/退出状态为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

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

brew install GDAL
一旦安装好

pip3.4 install gdal

今天有这个问题。在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

这终于对我起了作用。

效果很好,我尝试了所有其他解决方案,但什么都没有,但这一个效果很好: