python - 在 Python 中使用 Matplotlib.image 时出错

标签 python matplotlib pycharm

好的,所以我才开始this在 PyCharm 中使用 Anaconda 的教程。我导入了正确的库,但是当我尝试使用此代码上传图像时:

img = mpimg.imread('FileName.png')

我收到此错误消息:

Traceback (most recent call last): File "<input>", line 1, in <module> File ".../matplotlib/image.py", line 1323, in imread with open(fname, 'rb') as fd: IOError: [Errno 2] No such file or directory: 'FileName.png'

我试过像这样输入文件位置:

img=mpimg.imread('FilePath/FileName.png')

但是我得到了同样的错误。我想完全按照教程进行操作,所以我不确定为什么这不起作用!感谢您的帮助!

最佳答案

确保文件夹中有那个文件... 尝试使用此命令列出该文件夹中的文件,以确保 python 至少可以识别或读取这些文件。

import os
print (os.listdir('your path'))

关于python - 在 Python 中使用 Matplotlib.image 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37764266/

相关文章:

python - Flask/Jinja - 使用命令而不是页面加载显示数据库内容

python - 从 flask 中的 matplotlib 绘制 png 图显示原始数据

python - 如何调整matplotlib图表图形

python - 使用 BeautifulSoup 索引错误进行网页抓取

python - 具有结构数组的 Bigquery python SchemaField()

python - matplotlib 设置自己的轴值

python - PyCharm 2016 : How to display result without print command (like console)?

在OSX上的PyCharm中,matplotlib支持失败

python - Print 函数从类中打印两次字段

Python 列表的 Java 等价物