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