koegl
koegl

Reputation: 584

scipy has no attribute signal

I have a file which imports a function from another file, like shown below.

file1.py:

# import scipy.signal
import file2

file2.foo()

file2.py:

import scipy


def foo():
    scipy.signal.butter(2, 0.01, 'lowpass', analog=False)

When I run file1.py I get the following error:

File "file2.py", line 5, in foo scipy.signal.butter(2, 0.01, 'lowpass', analog=False) AttributeError: module 'scipy' has no attribute 'signal'

However, when I uncomment line 1 from file1.py (import scipy.signal) the error disappears. Why is this happening?

Upvotes: 4

Views: 6824

Answers (1)

falafelocelot
falafelocelot

Reputation: 588

With scipy, you need to import the submodule directly with either import scipy.signal or from scipy import signal. Many submodule won't work if you just import scipy. You can read about the scipy api here

Upvotes: 7

Related Questions