如何解决:collect2:错误:ld返回了1个退出状态错误:命令'x86_64-linux-gnu-gcc'失败,退出状态为1

时间:2019-08-01 11:37:29

标签: python python-2.7 ubuntu pygrib

我尝试安装pygrib软件包。在python 2。 我安装了所有必需的软件包。 (https://jswhit.github.io/pygrib/docs/pygrib-module.html) 我命令pip安装pygrib。但它有一个错误。 我在错误脚本中找不到错误。有很多警告。但是我不认为没有安装就没问题。

如何解决此错误?

  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-KuwhgZ/pygrib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-KuwhgZ/pygrib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-TKG3Ld --python-tag cp27
       cwd: /tmp/pip-install-KuwhgZ/pygrib/
  Complete output (38 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  copying ncepgrib2.py -> build/lib.linux-x86_64-2.7
  running build_ext
  skipping 'pygrib.c' Cython extension (up-to-date)
  building 'pygrib' extension
  creating build/temp.linux-x86_64-2.7
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -Ig2clib_src -I/usr/include/python2.7 -c pygrib.c -o build/temp.linux-x86_64-2.7/pygrib.o
  In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1822:0,
                   from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                   from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from pygrib.c:613:
  /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #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: In function '__pyx_pf_6pygrib_11gribmessage_16keys':
  pygrib.c:13996:18: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
       __pyx_v_name = grib_keys_iterator_get_name(__pyx_v_gi);
                    ^
  pygrib.c: In function '__pyx_pf_6pygrib_11gribmessage_18_read_only_keys':
  pygrib.c:14427:18: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
       __pyx_v_name = grib_keys_iterator_get_name(__pyx_v_gi);
                    ^
  pygrib.c: In function '__pyx_pf_6pygrib_11gribmessage_30tostring':
  pygrib.c:18559:53: warning: passing argument 2 of 'grib_get_message' from incompatible pointer type [-Wincompatible-pointer-types]
     __pyx_v_err = grib_get_message(__pyx_v_self->_gh, (&__pyx_v_message), (&__pyx_v_size));
                                                       ^
  In file included from pygrib.c:614:0:
  /usr/include/grib_api.h:554:5: note: expected 'const void **' but argument is of type 'void **'
   int grib_get_message(grib_handle* h ,const void** message, size_t *message_length);
       ^
  x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/pygrib.o -leccodes -o build/lib.linux-x86_64-2.7/pygrib.so
  /usr/bin/ld: cannot find -leccodes
  collect2: error: ld returned 1 exit status
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pygrib
  Running setup.py clean for pygrib
Failed to build pygrib
Installing collected packages: pygrib
  Running setup.py install for pygrib ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-KuwhgZ/pygrib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-KuwhgZ/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-NTYS3Y/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-KuwhgZ/pygrib/
    Complete output (38 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying ncepgrib2.py -> build/lib.linux-x86_64-2.7
    running build_ext
    skipping 'pygrib.c' Cython extension (up-to-date)
    building 'pygrib' extension
    creating build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -Ig2clib_src -I/usr/include/python2.7 -c pygrib.c -o build/temp.linux-x86_64-2.7/pygrib.o
    In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1822:0,
                     from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                     from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                     from pygrib.c:613:
    /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #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: In function '__pyx_pf_6pygrib_11gribmessage_16keys':
    pygrib.c:13996:18: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         __pyx_v_name = grib_keys_iterator_get_name(__pyx_v_gi);
                      ^
    pygrib.c: In function '__pyx_pf_6pygrib_11gribmessage_18_read_only_keys':
    pygrib.c:14427:18: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
         __pyx_v_name = grib_keys_iterator_get_name(__pyx_v_gi);
                      ^
    pygrib.c: In function '__pyx_pf_6pygrib_11gribmessage_30tostring':
    pygrib.c:18559:53: warning: passing argument 2 of 'grib_get_message' from incompatible pointer type [-Wincompatible-pointer-types]
       __pyx_v_err = grib_get_message(__pyx_v_self->_gh, (&__pyx_v_message), (&__pyx_v_size));
                                                         ^
    In file included from pygrib.c:614:0:
    /usr/include/grib_api.h:554:5: note: expected 'const void **' but argument is of type 'void **'
     int grib_get_message(grib_handle* h ,const void** message, size_t *message_length);
         ^
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/pygrib.o -leccodes -o build/lib.linux-x86_64-2.7/pygrib.so
    /usr/bin/ld: cannot find -leccodes
    collect2: error: ld returned 1 exit status
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-KuwhgZ/pygrib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-KuwhgZ/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-NTYS3Y/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

2 个答案:

答案 0 :(得分:1)

操作部分是cannot find -leccodes,这意味着它找不到库libeccodes.so

要安装它,

sudo apt install libeccodes-dev

答案 1 :(得分:0)

从2.0.2版开始,最新版本的pygrib要求使用称为ecCodes的ECMWF软件包来代替grib-api。您的gcc退出代码表示您缺少“ -leccodes”的编译标志。

ecCode可以在这里找到:https://confluence.ecmwf.int/display/ECC/ecCodes+Home 这是宣布将grib-api替换为ecCodes的地方:https://confluence.ecmwf.int/display/GRIB/Home

安装ecCodes软件包应提供gcc标志“ -leccodes”