python - 使用未声明的标识符 'NUMPY_IMPORT_ARRAY_RETVAL' 返回 NUMPY_IMPORT_ARRAY_RETVAL;

标签 python pandas numpy

无法安装 pysat 并收到一条长错误消息,其结尾如下所示。
错误信息:


    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.
转载
重现行为的步骤:
  • pip 安装 pysat

  • 设置:
  • 操作系统:MacOS Catalina
  • 10.15.7 (19H2)
  • Python:3.8
  • MacBook:MacBook Pro(15 英寸,2019 年)

  • 附加上下文
    在此处添加有关该问题的任何其他上下文。

    最佳答案

    我在不同的上下文和不同的架构(ubuntu)中遇到了类似的错误。
    错误提示是变量未声明名称为:NUMPY_IMPORT_ARRAY_RETVAL ;这包含对 numpy 的引用.
    第一:你有没有numpy安装了吗?如果没有,我会从那里开始。
    但是,就我而言,我不得不降级 numpy从 1.19.5.我无法告诉你该往哪个方向走numpy在你的情况下,因为我不知道你在做什么 - 但也许尝试修改 numpy版本?

    关于python - 使用未声明的标识符 'NUMPY_IMPORT_ARRAY_RETVAL' 返回 NUMPY_IMPORT_ARRAY_RETVAL;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64611523/

    相关文章:

    python - 为什么这个数组中的平均值大于最大值?

    python - 使用 sum、np.sum 和 fsum 对数组列表求和时会得到不同的结果吗?

    python - 如何测试由保存的异常引起的引用循环?

    python - 如何选择美丽汤列表中每个元素的第一个子元素

    Python 比较 char 和 hex

    python - Pandas 数据框数据透视表和分组

    python - 查询数据框以在 pandas 中创建新数据框

    python - ElementTree findall 'or' 运算符

    python - pandas - 根据列值将每行复制 'n' 次

    python - 查找两个图像的像素差异时出现IndexError