cannot import name 'imresize' from 'scipy.misc'
时间: 2023-10-11 13:04:32 浏览: 142
`imresize` function was removed from `scipy.misc` module in version 1.3.0. You can use `skimage.transform.resize` from scikit-image library instead.
Here is an example code:
```
from skimage.transform import resize
from imageio import imread
# Load image
img = imread('image.jpg')
# Resize image
resized_img = resize(img, (new_height, new_width), anti_aliasing=True)
```
Make sure to install scikit-image library if you haven't already:
```
pip install scikit-image
```
相关问题
cannot import name ‘imresize‘ from ‘scipy.misc‘
在Python的scipy.misc模块中不能导入imresize函数的问题可能是由于scipy版本的变化所致。在较新的版本中,imresize函数已被移除。因此,如果你使用的是较新的scipy版本,你将无法导入imresize函数。为了解决这个问题,你可以考虑使用其他库或方法来进行图像的尺寸调整。例如,你可以使用PIL库(Pillow)中的Image模块来进行图像的调整。另外,你也可以考虑使用scipy中的其他函数,如scipy.ndimage中的zoom函数来实现类似的功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [cannot import name 'imresize' from 'scipy.misc'](https://blog.csdn.net/infinita_LV/article/details/102669776)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* [ImportError: cannot import name imresize from scipy.misc](https://blog.csdn.net/u011573853/article/details/106302419)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
cannot import name 'imresize' from 'scipy.misc'怎么修正
这个问题可以通过安装scikit-image库来解决。你可以在终端或命令提示符中输入以下命令来安装:
pip install scikit-image
如果你已经安装了scikit-image,那么可以尝试更新它来解决该问题:
pip install --upgrade scikit-image
希望这能帮到你!
阅读全文