Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Can';t使用PIL打开照片_Python_Image_Python Imaging Library - Fatal编程技术网

Python Can';t使用PIL打开照片

Python Can';t使用PIL打开照片,python,image,python-imaging-library,Python,Image,Python Imaging Library,我尝试使用PIL打开照片,但无法打开 我怎样才能完成它 这是我的代码和错误消息: 从PIL导入图像 img=Image.open('test.png')) 文件“imagetest.py”,第3行,在 img=Image.open('test.png')) 文件“/anaconda3/lib/python3.7/site packages/PIL/Image.py”,第2687行,打开 %(如果文件名为fp,则为文件名) OSError:无法识别图像文件“test.png” 尝试提供映像的完整

我尝试使用PIL打开照片,但无法打开

我怎样才能完成它

这是我的代码和错误消息:

从PIL导入图像
img=Image.open('test.png'))
文件“imagetest.py”,第3行,在
img=Image.open('test.png'))
文件“/anaconda3/lib/python3.7/site packages/PIL/Image.py”,第2687行,打开
%(如果文件名为fp,则为文件名)
OSError:无法识别图像文件“test.png”

尝试提供映像的完整路径。仅传递文件名(不传递完整路径)作为参数,仅当映像与脚本文件位于同一目录中时才有效。尝试将完整路径作为@AchthaiHalage-Antiented传递。我不认为文件不在同一目录中是问题所在,听起来图像可能已损坏,您可以上载图像以验证它吗?
File "imagetest.py", line 3, in <module>
    img = Image.open('test.png')
File "/anaconda3/lib/python3.7/site-packages/PIL/Image.py", line 2687, in open
    % (filename if filename else fp))
OSError: cannot identify image file 'test.png'