jswhit / pygrib

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

Pygrib install error #115

Open Saszalez opened 5 years ago

Saszalez commented 5 years ago

I'm trying to install Pygrib with pip (pip install pygrib):

Collecting pygrib
  Using cached https://files.pythonhosted.org/packages/f8/10/c0d22eafec62fb5413799a7034ac45f26bfa77405c8527c17869e4c3ee4d/pygrib-2.0.4.tar.gz
Requirement already satisfied: numpy in ./lib/python3.7/site-packages (from pygrib) (1.16.4)
Installing collected packages: pygrib
  Running setup.py install for pygrib ... error
    ERROR: Complete output from command /home/python3/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-qcxz0945/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 /tmp/pip-record-qd474uhl/install-record.txt --single-version-externally-managed --compile:
    ERROR: /tmp/pip-install-qcxz0945/pygrib/setup.py:41: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
      config = _ConfigParser()
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    copying ncepgrib2.py -> build/lib.linux-x86_64-3.7
    running build_ext
    building 'pygrib' extension
    creating build/temp.linux-x86_64-3.7
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/python3/lib/python3.7/site-packages/numpy/core/include -Ig2clib_src -I/home/python3/include/python3.7m -c pygrib.c -o build/temp.linux-x86_64-3.7/pygrib.o
    In file included from /home/python3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822:0,
                     from /home/python3/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                     from /home/python3/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                     from pygrib.c:613:
    /home/python3/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: aviso: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it with " \
      ^
    pygrib.c:614:22: error fatal: grib_api.h: No existe el fichero o el directorio
     #include "grib_api.h"
                          ^
    compilación terminada.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command "/home/python3/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-qcxz0945/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 /tmp/pip-record-qd474uhl/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-qcxz0945/pygrib/

The versions are:

How can I fix this error?

astanway commented 5 years ago

Look at the error. “grib_api.h: No existe el fichero o el directorio

include "grib_api.h"“

You need to install libeccodes. grib_api is deprecated.

Saszalez commented 5 years ago

I installed libeccodes, but the installation of pygrib is still looking for the file grib_api.h

jswhit commented 5 years ago

libeecodes includes grib_api.h. You need to specify the path in setup.cfg

On Tue, Jun 25, 2019 at 8:23 AM Saszalez notifications@github.com wrote:

I installed libeccodes, but the installation of pygrib is still looking for the file grib_api.h

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jswhit/pygrib/issues/115?email_source=notifications&email_token=AAENQCLYY3VW65KV4GFROITP4IS5XA5CNFSM4H3IJQKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYQNKHQ#issuecomment-505468190, or mute the thread https://github.com/notifications/unsubscribe-auth/AAENQCPLIQKNIED6LUSKF3DP4IS5XANCNFSM4H3IJQKA .

-- Jeffrey S. Whitaker NOAA/OAR/PSD R/PSD1 325 Broadway, Boulder, CO, 80305-3328 Phone: (303)497-6313 FAX: (303)497-6449

Saszalez commented 5 years ago

Correct, the file grib_api.h is installed. The problem is that I do not have any setup.cfg file. The grib_api.h file is in the include path, how and where can I indicate that path?

Saszalez commented 5 years ago

Sorry to comment again. In the end, I set the environment variables:

export LDFLAGS='-L/my/libeccodes/path/lib' export CFLAGS='-I/my/libeccodes/path/lib'

Pygrib was installed correctly.

coolashish commented 4 years ago

@Saszalez Thanks for sharing the solution of setting environment variables. Do you mind sharing what was the actual path to libeccodes/lib on your machine? I have it installed but cannot find the path to lib/

Raymond089 commented 4 years ago

@coolashish A bit late, but i found that simply running pip3 install eccodes-python did the trick. No need to do any exports that way (Reference)

Edit: I was re-trying this on a clean install, its turns out that in addition to the above, the libeccodes-dev package needs to be installed locally. Which can by done by running sudo apt install libeccodes-dev

So, if you'd need to install this pygrib entirely from repositories you'd need to run the following:

sudo apt install libeccodes-dev pip3 install numpy pip3 install pyproj pip3 install eccodes-python pip3 install pygrib

This was tested on Ubuntu 18.04/Python3, clean install

maxshowarth commented 4 years ago

For anyone else who ends up here from Google, using CentOS, Conda, and Python 3.7.9, you can install directly from conda using:

conda install -c conda-forge pygrib

MarkUoLeeds commented 3 years ago

For anyone else who ends up here from Google, using CentOS, Conda, and Python 3.7.9, you can install directly from conda using:

conda install -c conda-forge pygrib

I recently updated my Anaconda3 on Win10 and this conda-forge technique fails with many "conflicts"

Anaconda 2020.07 for example:

Package spyder-kernels conflicts for:
spyder -> spyder-kernels[version='0.*|>=0.1,<1|>=0.4.2,<1|>=0.4.3,<1|>=0.5.0,<1|>=1.10.0,<1.11.0|>=1.9.4,<1.10.0|>=1.9.2,<1.10.0|>=1.9.1,<1.10.0|>=1.9.0,<1.10.0|>=1.8.1,<1.9.0|>=1.8.1,<2.0.0|<1.0']
anaconda==2020.07 -> spyder-kernels==1.9.2[build='py38_0|py36_0|py37_0']
anaconda==2020.07 -> spyder==4.1.4=py36_0 -> spyder-kernels[version='>=1.9.2,<1.10.0']
cahebert commented 3 years ago

@MarkUoLeeds I ran into the same problems as you describe (on Mac OS Catalina), and fixed it by running

conda install anaconda
conda update --all

before the conda install. Hope that helps!