简体   繁体   English

导入 APLpy 时出现 ImportError

[英]ImportError while importing APLpy

I keep getting this import error whenever I try to import APLpy in iPython after astropy.io.fits.每当我尝试在 astropy.io.fits 之后在 iPython 中导入 APLpy 时,我都会收到此导入错误。 I've tried uninstalling and reinstalling all my Python packages and libraries.我已经尝试卸载并重新安装我所有的 Python 包和库。 This error is causing kernel panic and I keep getting the login warning "You restarted your computer because of a problem".此错误导致 kernel 恐慌,我不断收到登录警告“由于出现问题,您重新启动了计算机”。

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)

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几天前在撰写本文时已修复此问题,并作为 v2.1.0 的一部分发布: https ://github.com/aplpy/aplpy/commit/e8c72f04c0a897fd2dc43bad0fb6eeab0c413768

It was just a slight incompatibility with Astropy 5.0.这只是与 Astropy 5.0 的轻微不兼容。

First upgrade astropy with: pip install astropy --upgrade首先升级astropy: pip install astropy --upgrade

Now uninstall aplpy: pip uninstall aplpy现在卸载 aplpy: pip uninstall aplpy

Then install it again: pip install aplpy然后再次安装: pip install aplpy

It should work now.它现在应该可以工作了。

Just uninstall aplpy and then install again.只需卸载 aplpy 然后重新安装即可。 It works for me as I am using astropy version astropy==5.1它对我有用,因为我使用的是 astropy 版本 astropy==5.1

pip uninstall aplpy pip 卸载aplpy

and Install again--并再次安装——

pip install aplpy pip 安装 aplpy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM