jswhit / pygrib

Python interface for reading and writing GRIB data
https://jswhit.github.io/pygrib
MIT License
319 stars 93 forks source link

Cannot install pygrib due to missing component #230

Open heliosilver97 opened 4 months ago

heliosilver97 commented 4 months ago

Good afternoon!

I'm trying to install the pygrib library to run in VS Code, but I'm not succeeding. When I go to install, the following reason appears:

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pygrib Failed to build pygrib ERROR: Could not build wheels for pygrib, which is required to install pyproject.toml-based projects

I researched the error and i found that the error suggests that the build process of the pygrib package is failing due to the absence of the grib_api.h file, which is part of the libeccodes library. How i can fix this issue? Because i already installed the eccodes package, and the same issue still happens.

jswhit2 commented 4 months ago

if you use 'pip install' it should install a binary (no need to compile, all required c-libs bundled). x86_64 windows and linux wheels are available for python 3.7-3.12. What platform/python version are you using?

fguenot commented 3 months ago

I have the same problem. I use Python 3.12.0 on Windows 11. Here is the output error :

error: subprocess-exited-with-error

  × Building wheel for pygrib (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      eccodes not found, build may fail...
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-312
      creating build\lib.win-amd64-cpython-312\pygrib
      copying src\pygrib\__init__.py -> build\lib.win-amd64-cpython-312\pygrib
      running build_ext
      <string>:17: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !! ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try pip install --use-pep517.
              ********************************************************************************
      !!
      C:\Users\francois.guenot\AppData\Local\Temp\pip-build-env-x0ftwyx7\overlay\Lib\site-packages\Cython\Compiler\Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: C:\Users\francois.guenot\AppData\Local\Temp\pip-install-p0qxo4bt\pygrib_2fb375a25c524c26b77b9f49463c89fc\src\pygrib\_pygrib.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      warning: src\pygrib\_pygrib.pyx:351:12: Unreachable code
      Compiling src/pygrib/_pygrib.pyx because it changed.
      [1/1] Cythonizing src/pygrib/_pygrib.pyx
      building 'pygrib._pygrib' extension
      creating build\temp.win-amd64-cpython-312
      creating build\temp.win-amd64-cpython-312\Release
      creating build\temp.win-amd64-cpython-312\Release\src
      creating build\temp.win-amd64-cpython-312\Release\src\pygrib
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\francois.guenot\PycharmProjects\versdevcarto02-test\.venv\inc
lude -IC:\Users\francois.guenot\AppData\Local\Programs\Python\Python312\include -IC:\Users\francois.guenot\AppData\Local\Programs\Python\Python312\Include -IC:\Users\francois.guenot\AppData\Local\Temp\pip-build-env-x0ftwyx7\over
lay\Lib\site-packages\numpy\core\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\incl
ude" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /Tcsrc/pygrib/_pygrib.c /Fobuild\temp.win-amd64-cpython-312\Release\src/pygrib/_pygrib.obj   
      _pygrib.c
      C:\Users\francois.guenot\AppData\Local\Temp\pip-build-env-x0ftwyx7\overlay\Lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
      src/pygrib/_pygrib.c(1221): fatal error C1083: Impossible d'ouvrir le fichier includeÿ: 'grib_api.h'ÿ: No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

[end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pygrib
Failed to build pygrib
ERROR: Could not build wheels for pygrib, which is required to install pyproject.toml-based projects

I looked for a solution, but I can't find it. Thanks for your help.

Regards

jswhit2 commented 3 months ago

sorry I misspoke earlier - we only have macosx and linux binary wheels. Windows is not supported. However, it looks like you can install pygrib on windows via conda (https://anaconda.org/conda-forge/pygrib)

jswhit commented 3 months ago

@fguenot @heliosilver97 please let us know if you're able to get up and running using the conda package

jswhit commented 1 week ago

You can use the ECCODES_DIR env var (see https://jswhit.github.io/pygrib/installing.html#instructions)