AttributeError: type object ‘Image‘ has no attribute ‘open‘
生活随笔
收集整理的這篇文章主要介紹了
AttributeError: type object ‘Image‘ has no attribute ‘open‘
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
AttributeError: type object ‘Image‘ has no attribute ‘open‘
原因分析:Image調(diào)用順序出錯(cuò),因?yàn)榈谝恍械膄rom PIL import Image與第二行tkinter import *沖突,tkinter中也含有Image類,所以你使用的是tkinter.Image
解決方法:from PIL import Image as imim
原調(diào)用順序
try:from PIL import Image except ImportError:import Imageimport tkinter as tk from tkinter import * from tkinter import filedialog原調(diào)用順序
import tkinter as tk from tkinter import * from tkinter import filedialogtry:from PIL import Image except ImportError:import Image總結(jié)
以上是生活随笔為你收集整理的AttributeError: type object ‘Image‘ has no attribute ‘open‘的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 智慧交通day03-车道线检测实现06:
- 下一篇: PyTorch的nn.Linear()详