我在用那个密码
```
periods = np.linspace(0.5, 20, 10)
durations = np.linspace(0.05, 0.2, 10)
from astropy.stats import BoxLeastSquares
bls = BoxLeastSquares(t=time, y=flux, dy=flux_err)
bls.power(periods, durations)
```
但它返回了一个错误
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-d582b87a594f> in <module>()
2 durations = np.linspace(0.05, 0.2, 10)
3
----> 4 from astropy.stats import BoxLeastSquares
5 bls = BoxLeastSquares(t=time, y=flux, dy=flux_err)
6 bls.power(periods, durations)
ImportError: cannot import name 'BoxLeastSquares'
---------------------------------------------------------------------------
我不知道该如何更正,它发生在lightkurve模块的新更新之前 我使用的是3.0.5版
你使用的是什么版本的Astropy?根据these docs
这在最新版本中适用于我:
一般来说,如果您在Astropy之类的库中为函数或类获得了一个
ImportError
,而您认为它应该在那里,这仅仅意味着它不存在,因此您应该通过查看astropy.__version__
仔细检查您的版本,并将其与该版本的API文档进行比较,以确保您尝试导入的内容实际存在相关问题 更多 >
编程相关推荐