我正在尝试使用类似以下代码的方式将图像文件加载到ndarray中:
image_data = ndimage.imread(image_file).astype(float)
但是我遇到了这个错误:
/home/milos/anaconda3/envs/tensorflow/lib/python3.5/site-packages/scipy/ndimage/io.py in imread(fname, flatten, mode)
23 if _have_pil:
24 return _imread(fname, flatten, mode)
---> 25 raise ImportError("Could not import the Python Imaging Library (PIL)"
26 " required to load image files. Please refer to"
27 " http://pypi.python.org/pypi/PIL/ for installation"
ImportError: Could not import the Python Imaging Library (PIL) required to load image files. Please refer to http://pypi.python.org/pypi/PIL/ for installation instructions.
我已经在运行笔记本的环境中安装了Pillow,它也出现在pip freeze中。我还尝试从控制台运行它,但是出现了类似的错误。
有什么想法如何解决这个问题吗?或者有没有其他方法将图像加载到ndarray中?