AttributeError: 'module' object (scipy) has no attribute *** 为什么会出现这个错误? [英] AttributeError: 'module' object (scipy) has no attribute *** Why does this error occur?

查看:117
本文介绍了AttributeError: 'module' object (scipy) has no attribute *** 为什么会出现这个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 scipy 中,错误经常发生.

<预><代码>>>>进口scipy>>>scipy.integrate.trapz(陀螺系列,时间系列)回溯(最近一次调用最后一次):文件<stdin>",第 1 行,在 <module> 中AttributeError: 'module' 对象没有属性 'integrate'>>>

我通过执行以下操作找出了如何解决此问题的方法:

<预><代码>>>>>>>导入 scipy.integrate>>>scipy.integrate.trapz(陀螺系列,时间系列)>>>1.2

我的问题:

为什么会出现错误?

为什么要修复错误?

解决方案

很可能是因为scipy是一个包含模块的库(包),要从scipy库中导入特定的模块,需要指定并导入模块本身.因为它是一个单独的模块(子包),一旦你导入它,它的属性就可以通过使用常规的 scipy.module.attribute

In scipy, the error occurs quite often.

>>> import scipy
>>> scipy.integrate.trapz(gyroSeries, timeSeries)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'integrate'
>>> 

I figure out how to solve this problem by doing the following:

>>> 
>>> import scipy.integrate
>>> scipy.integrate.trapz(gyroSeries, timeSeries)
>>> 1.2

My question:

Why does the error occur?

Why would that fix the error?

解决方案

Most possibly because scipy is a library (package) that contains modules and to import a specific module from the scipy library, you need to specify it and import the module itself. As it's a separate module (sub-package), once you import it, it's attributes are available to you by using the regular scipy.module.attribute

这篇关于AttributeError: 'module' object (scipy) has no attribute *** 为什么会出现这个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆