导入 APLpy 时出现导入错误

发布于 2025-01-13 11:03:55 字数 1200 浏览 0 评论 0原文

每当我尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

滥情哥ㄟ 2025-01-20 11:03:55

这个问题在撰写本文时几天前已修复,并作为 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.

浪荡不羁 2025-01-20 11:03:55

首先升级astropy

pip install astropy --upgrade

现在卸载aplpy

pip uninstall aplpy

然后再次安装:

pip install aplpy

它现在应该可以工作了。

First upgrade astropy with:

pip install astropy --upgrade

Now uninstall aplpy:

pip uninstall aplpy

Then install it again:

pip install aplpy

It should work now.

淡淡绿茶香 2025-01-20 11:03:55

只需卸载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

誰ツ都不明白 2025-01-20 11:03:55

请注意:在撰写本文时(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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文