我试图在Python中使用matplotlib打开JPG图像。编辑'Spyder',Python3.6,WIndows 7
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
# Read in the image and print some stats
image = mpimg.imread(r'C:\Users\xxx\Python Code\mountain.jpg')
print('This image is: ',type(image),
'with dimensions:', image.shape)
但我收到以下错误...它说除了'.png'之外没有其他图像格式支持。
错误: - image = mpimg.imread(r'C:\ Users \ xxx \ Python Code \ mountain.jpg')
File "C:\temp\Continuum\anaconda3\lib\site-packages\matplotlib\image.py",
line 1284, in imread
'more images' % list(handlers))
ValueError: Only know how to handle extensions: ['png']; with Pillow
installed matplotlib can handle more images.
我经历了各种文件。其中说,为了打开'.jpg'图像,必须安装'Pillow'。如果原生matplotlib调用无法打开图像,那么它会自动回落到“枕头”上。 (如果我错了,请纠正我)
所以我安装了“枕头”。但我仍然得到错误。
你能告诉我我想念的是什么吗? (奇怪的是这个代码在另一台计算机上运行。我无法验证该机器中安装的库)