AttributeError: 'module' object (scipy) has no attribute 'misc'

前端 未结 4 747
無奈伤痛
無奈伤痛 2020-12-01 09:58

I updated from ubuntu 12.04 to ubuntu 12.10 and the python module I have written suddenly no longer works with the error message that the module scipy does not have the attr

相关标签:
4条回答
  • 2020-12-01 10:41

    imread is depreciated after version 1.2.0 ! So to solve the problem I had to install 1.1.0 version.

     pip install scipy==1.1.0
    
    0 讨论(0)
  • 2020-12-01 10:48
    1. You need to explicitly import scipy.misc as:

      import scipy.misc

    2. You need to install the package pillow (formerly known as PIL), if not already installed. For image manipulation functions of scipy.misc such as imread() or imsave() to function correctly, pillow has to be installed. To verify, either run your code again or type the below command:

      scipy.misc.imread

    0 讨论(0)
  • 2020-12-01 10:53
    >>> import scipy
    >>> scipy.misc
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'module' object has no attribute 'misc'
    >>> 
    >>> 
    >>> import scipy.misc
    >>> scipy.misc.imsave
    <function imsave at 0x19cfa28>
    >>>
    

    Which seems to be quite common with scipy.

    0 讨论(0)
  • 2020-12-01 10:53

    Because you cannot directly use the misc module from scipy without explicitly import it. Here is the way of loading scipy.misc:

    import scipy.misc
    
    #Load the Lena image into an array, (yes scipy does have a lena function)
    lena = scipy.misc.lena()
    ...
    
    0 讨论(0)
提交回复
热议问题