'ImportError while importing APLpy

I keep getting this import error whenever I try to import APLpy in iPython after astropy.io.fits. I've tried uninstalling and reinstalling all my Python packages and libraries. This error is causing kernel panic and I keep getting the login warning "You restarted your computer because of a problem".

ImportError                               Traceback (most recent call last)
<ipython-input-2-ab2ae99f459c> in <cell line: 1>()
----> 1 import aplpy

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aplpy/__init__.py in <module>
     12 if not _ASTROPY_SETUP_:  # noqa
     13 
---> 14     from .core import FITSFigure  # noqa
     15     from .rgb import make_rgb_image, make_rgb_cube  # noqa
     16 

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/aplpy/core.py in <module>
     18 from astropy.wcs.utils import proj_plane_pixel_scales
     19 from astropy.io import fits
---> 20 from astropy.nddata.utils import block_reduce
     21 from astropy.visualization import AsymmetricPercentileInterval
     22 from astropy.visualization.wcsaxes import WCSAxes, WCSAxesSubplot

ImportError: cannot import name 'block_reduce' from 'astropy.nddata.utils' (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/astropy/nddata/utils.py)


Solution 1:[1]

This was fixed just a few days ago as of writing, and released as part of v2.1.0: https://github.com/aplpy/aplpy/commit/e8c72f04c0a897fd2dc43bad0fb6eeab0c413768

It was just a slight incompatibility with Astropy 5.0.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Iguananaut