I am trying to install pyregion (a package related to astronomical data analysis) under python 3.9.6 and MacOS Sonoma 14.3.1.
I have tried various ways but always encounter new obstacles. After the standard method: pip3 install pyregion which fails with an error message "Failed building wheel for pyregion". and after trying many other suggestions found here on stackoverflow, including upgrading numpy, upgrading pip3 itself, and also python3 -m pip install pyregion
I am now trying the direct installation of the files, which can be found here: https://pypi.org/project/pyregion/#files
The first obstacle to running
python3 setup.py install
was:
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'*
I then also installed Cython
pip3 install --upgrade cython
Which successfully installed cython-3.0.9 for me. Trying again running the setup.py, I get a long error message ending with:
/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
I would really need step by step instructions. My environment is up to date and I don't understand why this particular package gives these problems, while other packages like astropy and matplotlib work perfectly.
You should probably put in a request with the maintainers to fix that. I was able to reproduce the issue easily. It looks like they've fallen behind on on keeping up with the environments.
I am going to assume the code was written correctly, which may not be the case. The maintainers need to address this. You may have issues if there is indeed a bug. With that in mind, I was able to get past the "error: incompatible pointer to integer conversion" by adding the -Wno-int-conversion
compiler flag when installing, which tells the compiler this conversion is actually OK.
CFLAGS="-Wno-int-conversion" pip install pyregion
For completeness, I did this work using virtual environments. I do not expect that to matter.