tkinter- 报错-AttributeError: type object ‘Image‘ has no attribute ‘open‘

AttributeError: type object 'Image' has no attribute 'open'

原因分析:Image调用顺序出错

  • 原调用顺序
try:
    from PIL import Image
except ImportError:
    import Image

import tkinter as tk
from tkinter import *
from tkinter import filedialog
  • 调整调入顺序,from PIL import Image
import tkinter as tk
from tkinter import *
from tkinter import filedialog

try:
    from PIL import Image
except ImportError:
    import Image

问题解决

你可能感兴趣的:(报错,python,tkinter,debug)