pip安装包 - 失败,错误代码为1/2
问题描述:
我遇到安装问题pygrib
使用pip
。我尝试使用easy_install
安装pygrib
,并且出现类似错误。pip安装包 - 失败,错误代码为1/2
使用pip
我得到这个错误:
Command "C:\Users\Brandon\AppData\Local\Enthought\Canopy\edm\envs\User\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Brandon\\AppData\\Local\\Temp\\pip-build-veulay9n\\pygrib\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Brandon\AppData\Local\Temp\pip-ff_s5247-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Brandon\AppData\Local\Temp\pip-build-veulay9n\pygrib\
使用easy_install
我得到这个错误:
c:\users\brandon\appdata\local\enthought\canopy\edm\envs\user\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
pygrib.c(242): fatal error C1083: Cannot open include file: 'grib_api.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
事实上,pygrib
只有当我尝试pip
或不工作包easy_install
- 适用于我尝试安装的任何软件包。这里发生了什么,我该如何解决这个问题?
答
pygrib
是libgrib-api
的Python包装。要编译pygrib
,您需要编译libgrib-abi
并安装库和头文件。从https://software.ecmwf.int/wiki/display/GRIB/Releases下载源代码。
答
pygrib
包括一个或多个用C语言编写的Python扩展模块,它们需要作为安装的一部分进行编译,而这个C代码依赖于某个提供名为“grib_api.h
”的头文件的库。找到并安装该C库,然后安装pygrib
即可工作。
请注意,[Windows支持是实验性的](https://software.ecmwf.int/wiki/pages/viewpage.action?pageId=48109524),尽管如果您知道自己的“如果您不熟悉在Windows中编译C代码或设置环境变量,那么说明并不是非常有用。 –