Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scipy has no attribute signal

Tags:

python

scipy

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?

like image 858
koegl Avatar asked Oct 28 '25 09:10

koegl


1 Answers

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

like image 122
falafelocelot Avatar answered Oct 31 '25 12:10

falafelocelot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!