Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'module' object (scipy) has no attribute *** Why does this error occur?

Tags:

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?

like image 751
Sibbs Gambling Avatar asked Aug 05 '13 02:08

Sibbs Gambling


People also ask

How do you solve the module has no attribute in Python?

To solve the Python "AttributeError: module has no attribute", make sure you haven't named your local modules with names of remote modules, e.g. datetime.py or requests.py and remove any circular dependencies in import statements.

What does it mean when a module has no attribute?

It's simply because there is no attribute with the name you called, for that Object. This means that you got the error when the "module" does not contain the method you are calling.

What is attribute error in Python?

AttributeError can be defined as an error that is raised when an attribute reference or assignment fails. For example, if we take a variable x we are assigned a value of 10. In this process suppose we want to append another value to that variable. It's not possible.

How do I import a Scipy library?

Install SciPy using the pip command Python consists of pip command which is an official package installer. It is a package manager, we can install, delete, or update any package. We need to install pip for using the pip command. Once the requirement is satisfied we can use the pip command in terminal.


1 Answers

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

like image 140
Amit Avatar answered Sep 22 '22 23:09

Amit