python scipy.misc derivative_module 'scipy.misc' has no attribute 'toimage'

在跑See-in-the-dark模型的时候出现了这个问题。

根据Scipy官方文档的说法,scipy.misc.toimage在1.2.1之后的版本中已经被移除了,所以要做的第一件是就是降级:

pip install scipy==1.2.1

如果你下载了之后还是用不了的话,可以先看看这个库的属性:

dir(scipy.misc)['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_comb', '_fact', '_fact2', '_factk', '_info', '_lsm', '_msg', '_pade', '_source', '_who', 'absolute_import', 'ascent', 'central_diff_weights', 'comb', 'derivative', 'division', 'doccer', 'electrocardiogram', 'face', 'factorial', 'factorial2', 'factorialk', 'info', 'logsumexp', 'np', 'pade', 'print_function', 'source', 'test', 'who']

怎么还是没有'toimage'呢?

通过翻阅misc的文件,我发现toimage被写在了pilutil.py文件里,而这个文件的开头有说明:A collection of image utilities using the Python Imaging Library (PIL).

Note that PIL is not a dependency of SciPy and this module is not available on systems that don't have PIL installed.

所以只有安装了pillow之后,才会显示这个属性。

pip install pillow

现在再来看scipy.misc的属性就有了:['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '_comb', '_fact', '_fact2', '_factk', '_info', '_lsm', '_msg', '_pade', '_source', '_who', 'absolute_import', 'ascent', 'bytescale', 'central_diff_weights', 'comb', 'derivative', 'division', 'doccer', 'electrocardiogram', 'face', 'factorial', 'factorial2', 'factorialk', 'fromimage', 'imfilter', 'imread', 'imresize', 'imrotate', 'imsave', 'imshow', 'info', 'logsumexp', 'np', 'pade', 'print_function', 'source', 'test', 'toimage', 'who']

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值