Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pygrib install error #115

Open
Saszalez opened this issue Jun 25, 2019 · 10 comments
Open

Pygrib install error #115

Saszalez opened this issue Jun 25, 2019 · 10 comments

Comments

@Saszalez
Copy link

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:

  • Numpy (1.16.4)
  • Python (3.7.3)
  • Pip (19.1.1)

How can I fix this error?

@astanway
Copy link

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
Copy link
Author

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

@jswhit
Copy link
Owner

jswhit commented Jun 25, 2019 via email

@Saszalez
Copy link
Author

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
Copy link
Author

Saszalez commented Jun 26, 2019

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
Copy link

@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
Copy link

Raymond089 commented Jan 29, 2020

@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
Copy link

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
Copy link

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
Copy link

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants