尝试使用枕头/ PIL库时不理解此FileNotFoundError

时间:2018-10-28 16:50:05

标签: python python-imaging-library

在下面的代码中,我试图使用pythons pillow / PIL库。这是第一次使用它,我只是试图打开我的图像以确保其正常工作。我有下面使用的代码。我只是用谷歌搜索图像,并使用名称smallhouse.jpg保存了它。但是,我在下面遇到以下错误。

import numpy as np
from PIL import Image
img = Image.open('smallhouse.jpg')
img.show()

这是我遇到的错误。我需要下载PIL软件包吗?我正在使用木星笔记本。

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-10-e26e3b39215f> in <module>()
  1 import numpy as np
  2 from PIL import Image
----> 3 img = Image.open('smallhouse.jpg')
  4 img.show()

~\Anaconda3\lib\site-packages\PIL\Image.py in open(fp, mode)
2546
2547     if filename:
-> 2548         fp = builtins.open(filename, "rb")
2549         exclusive_fp = True
2550

 FileNotFoundError: [Errno 2] No such file or directory: 'smallhouse.jpg'

1 个答案:

答案 0 :(得分:0)

这里描述的问题:

interfaceWithRoute

请确保将图像文件FileNotFoundError: [Errno 2] No such file or directory: 'smallhouse.jpg'与笔记本电脑放在同一目录中。

相关问题