gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 03:11:48 24 4
gpt4 key购买 nike

好的,所以我才开始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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com