在学习pytorch使用时,运行下面的代码出现报错
ImportError: DLL load failed while importing _imaging: 找不到指定的模块。
from PIL import Image
import numpy as np
img_path = "dataset/train/ants/0013035.jpg"
img = Image.open(img_path)
print(type(img))
img_arr = np.array(img)
print(type(img_arr))
原因
pillow与python版本不匹配
解决办法
pip uninstall pillow
pip install pillow==6.2.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/
也可参考该博客
https://blog.csdn.net/weixin_41577588/article/details/130353201