use of undeclared identifier 'NUMPY_IMPORT_ARRAY_RETVAL' return NUMPY_IMPORT_ARRAY_RETVAL;

Viewed 2752

Failed to install pysat and got a long error message which ended like the following.

Error message:


    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/<home>/opt/anaconda3/envs/py38/include -arch x86_64 -I/Users/<home>/opt/anaconda3/envs/py38/include -arch x86_64 -Ipandas/_libs/src/ujson/python -Ipandas/_libs/src/ujson/lib -Ipandas/_libs/src/datetime -I/Users/<home>/opt/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/core/include -I/Users/<home>/opt/anaconda3/envs/py38/include/python3.8 -c pandas/_libs/src/ujson/python/objToJSON.c -o build/temp.macosx-10.9-x86_64-3.8/pandas/_libs/src/ujson/python/objToJSON.o -D_GNU_SOURCE -Wno-unused-function
    In file included from pandas/_libs/src/ujson/python/objToJSON.c:44:
    In file included from /Users/<home>/opt/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4:
    In file included from /Users/<home>/opt/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
    In file included from /Users/<home>/opt/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822:
    /Users/<home>/opt/anaconda3/envs/py38/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with "          "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
    #warning "Using deprecated NumPy API, disable it with " \
     ^
    pandas/_libs/src/ujson/python/objToJSON.c:194:12: error: use of undeclared identifier 'NUMPY_IMPORT_ARRAY_RETVAL'
        return NUMPY_IMPORT_ARRAY_RETVAL;
               ^
    1 warning and 1 error generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
  Rolling back uninstall of pandas
  Moving to /Users/<home>/opt/anaconda3/envs/py38/lib/python3.8/site-packages/pandas-1.0.3.dist-info/
   from /Users/<home>/opt/anaconda3/envs/py38/lib/python3.8/site-packages/~andas-1.0.3.dist-info
  Moving to /Users/<home>/opt/anaconda3/envs/py38/lib/python3.8/site-packages/pandas/
   from /Users/<home>/opt/anaconda3/envs/py38/lib/python3.8/site-packages/~andas
ERROR: Command errored out with exit status 1: /Users/<home>/opt/anaconda3/envs/py38/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/5p/_ydvdq5959v8p0kntv58swdc0000gn/T/pip-install-rnh260bm/pandas/setup.py'"'"'; __file__='"'"'/private/var/folders/5p/_ydvdq5959v8p0kntv58swdc0000gn/T/pip-install-rnh260bm/pandas/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/5p/_ydvdq5959v8p0kntv58swdc0000gn/T/pip-record-53ycqncw/install-record.txt --single-version-externally-managed --compile --install-headers /Users/<home>/opt/anaconda3/envs/py38/include/python3.8/pandas Check the logs for full command output.

To Reproduce Steps to reproduce the behavior:

  1. pip install pysat

Setup:

  • OS: MacOS Catalina
  • 10.15.7 (19H2)
  • Python: 3.8
  • MacBook: MacBook Pro (15-inch, 2019)

Additional context Add any other context about the problem here.

1 Answers

I got a similar error in a different context and a different architecture (ubuntu).

A hint from the error is that a variable is undeclared with the name: NUMPY_IMPORT_ARRAY_RETVAL; this contains a reference to numpy.

First: Do you have numpy installed? If not, I'd start there.

But, in my case, I had to downgrade numpy from 1.19.5. I can't tell you which direction you have to go with numpy in your case since I don't know what you're on - but perhaps try modifying the numpy version?

Related