导入 APLpy 时出现导入错误
每当我尝试在 astropy.io.fits 之后在 iPython 中导入 APLpy 时,我都会收到此导入错误。我尝试卸载并重新安装所有 Python 包和库。此错误导致内核恐慌,并且我不断收到登录警告“由于出现问题,您重新启动了计算机”。
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个问题在撰写本文时几天前已修复,并作为 v2.1.0 的一部分发布: https://github.com/aplpy/aplpy/commit/e8c72f04c0a897fd2dc43bad0fb6eeab0c413768
这只是与 Astropy 5.0 略有不兼容。
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.
首先升级
astropy
:现在卸载
aplpy
:然后再次安装:
它现在应该可以工作了。
First upgrade
astropy
with:Now uninstall
aplpy
:Then install it again:
It should work now.
只需卸载apply,然后重新安装即可。它对我有用,因为我正在使用 astropy 版本 astropy==5.1
pip uninstall aplpy
并再次安装 -
pip install aplpy
Just uninstall aplpy and then install again. It works for me as I am using astropy version astropy==5.1
pip uninstall aplpy
and Install again--
pip install aplpy
请注意:在撰写本文时(2023 年 8 月),v.2.0.3 仍然是 Conda 中包含的 Aplpy 的最高版本,因此必须卸载 Conda 版本并安装 pip 版本才能使其工作直到 Conda 人员将 Aplpy 版本升级为未损坏的版本。
Just a heads-up: At the time of writing (August 2023), v. 2.0.3 is still the highest version of Aplpy included in Conda, so one will have to uninstall the Conda version and install the pip version to make it work until the Conda folks bump the Aplpy version to something that is not broken.