我正在尝试在python 3.9.6和MacOS Sonoma 14.3.1下安装pyregion(与天文数据分析相关的软件包)。
我尝试过各种方法,但总是遇到新的障碍。 标准方法后: pip3安装pyregion 失败并显示错误消息 “pyregion 构建轮子失败”。 在尝试了 stackoverflow 上找到的许多其他建议之后,包括升级 numpy、升级 pip3 本身,以及 python3 -m pip install pyregion
我现在正在尝试直接安装文件,可以在这里找到: https://pypi.org/project/pyregion/#files
跑步的第一个障碍
python3 setup.py install
是:
Traceback (most recent call last):
File "/Users/claudiopedrazzi/Downloads/pyregion-2.2.0/setup.py", line 5, in <module>
from Cython.Build import cythonize
ModuleNotFoundError: No module named 'Cython'*
然后我还安装了 Cython
pip3 install --upgrade cython
这为我成功安装了 cython-3.0.9。 再次尝试运行 setup.py,我收到一条以以下结尾的长错误消息:
/Users/claudiopedrazzi/Library/Python/3.9/lib/python/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 " \
^
pyregion/_region_filter.c:18264:3: error: incompatible pointer to integer conversion returning 'void *' from a function with result type 'int' [-Wint-conversion]
import_array();
^~~~~~~~~~~~~~
/Users/claudiopedrazzi/Library/Python/3.9/lib/python/site-packages/numpy/core/include/numpy/__multiarray_api.h:1558:151: note: expanded from macro 'import_array'
#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NULL; } }
^~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include/stddef.h:89:16: note: expanded from macro 'NULL'
# define NULL ((void*)0)
^~~~~~~~~~
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
我真的需要一步一步的指导。我的环境是最新的,我不明白为什么这个特定的包会出现这些问题,而其他包(如 astropy 和 matplotlib)却可以完美工作。
您可能应该向维护人员提出修复该问题的请求。我能够轻松地重现该问题。看起来他们在跟上环境方面已经落后了。
我假设代码编写正确,但情况可能并非如此。维护者需要解决这个问题。如果确实存在错误,您可能会遇到问题。 考虑到这一点,我能够通过在安装时添加
-Wno-int-conversion
编译器标志来克服“错误:整数转换不兼容的指针”,该标志告诉编译器此转换其实还可以。
CFLAGS="-Wno-int-conversion" pip install pyregion
为了完整起见,我使用虚拟环境完成了这项工作。我认为这并不重要。