Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

scipy.signal not defined, but works after importing skimage

I would like to use scipy.signal.convolve2d() function from SciPy, but signal is undefined:

>>> import scipy
...
>>> conv = scipy.signal.convolve2d(data, kernel, mode="same")

Error: Traceback (most recent call last):
  File "test.py", line n, in <module>
    conv = scipy.signal.convolve2d(data, kernel, mode="same")
AttributeError: module 'scipy' has no attribute 'signal'.

But when I add skimage import:

from skimage.morphology import square

or

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

from skimage.morphology import disk

It suddenly starts to be defined, and works fine. Any ideas why and how to fix it properly, so it wouldn’t need unused import? Skimage is a totally different thing, not related (at least in theory).

Lib versions:

scikit-image              0.19.2           py37hf11a4ad_0    anaconda
scikit-learn              1.0.2            py37hf11a4ad_1
scipy                     1.7.3            py37h0a974cb_0

Python version:

Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]

>Solution :

Use

import scipy.signal

to make sure you import the SciPy Signal subpackage.

import skimage probably imports scipy.signal under the hood, so the subpackage is available in the namespace; normally, you need to do this yourself.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading