Python 如何修复TypeError:\uuuu init\uuuuuu()至少接受2个参数(给定1个)错误

Python 如何修复TypeError:\uuuu init\uuuuuu()至少接受2个参数(给定1个)错误,python,tkinter,wand,Python,Tkinter,Wand,我试图将上传的pdf文件拆分为图像,但我遇到了错误,如获取至少2个参数(1个参数) 我知道这个错误已经被问到了,但我很困惑,无法在我的程序中修复 from pyPdf import PdfFileWriter, PdfFileReader from wand.image import Image import os from Tkinter import * from tkFileDialog import askopenfilename root =Tk() root.geometry("5

我试图将上传的pdf文件拆分为图像,但我遇到了错误,如获取至少2个参数(1个参数)

我知道这个错误已经被问到了,但我很困惑,无法在我的程序中修复

from pyPdf import PdfFileWriter, PdfFileReader
from wand.image import Image
import os

from Tkinter import *
from tkFileDialog import askopenfilename
root =Tk()
root.geometry("500x500")

class MyFrame(Frame):
    def __init__(self):
        Frame.__init__(self)
        self.master.title("pdf")
        self.master.rowconfigure(5, weight=1)
        self.master.columnconfigure(5, weight=1)
        self.grid(sticky=W+E+N+S)
        label = Label(self,text="Upload a pdf file",font = ('Arial' , 25))
        label.pack()
        self.Label1=Label(self)
        self.Label1.pack()
        self.button = Button(self, text="Upload", command=self.load_file, fg="red", width=10).pack(side=TOP, expand=YES)
        self.pack(fill=BOTH, expand=YES)

    def load_file(self):
        fname = askopenfilename()
        self.Label1.config(text=os.path.basename(fname), fg="blue")
        self.im = Image(filename=fname, resolution=200)
        for i, page in enumerate(im.sequence):
            with Image(page) as page_image:
                page_image.alpha_channel = False
                page_image.save(filename='page-%s.png' % i)

        print "suceSsfully"
if __name__ == "__main__":
    MyFrame().mainloop()
每当我运行此代码时,都会出现此错误


Tkinter
有自己的
Image
class
Tkinter.Image
。 导入
wand.image.image
后从Tkinter导入所有时,您将开始使用
Tkinter
中的
image
类。
您应该将
Tkinter
导入为
将Tkinter导入为tk
,并将其与
tk.class\u name
一起使用,或者直接使用
wand.image.image
而不是
image

你没有看到右侧相关列表中所有类似的问题吗?是的,我看到了,但我对它感到困惑。请帮我弄清楚错误发生在哪一行?回溯的完整错误是什么?文件“root.py”,第27行,在load\u File self.im=Image(filename=fname,resolution=200)TypeError:\uuu init\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu()至少需要2个参数(给定1个),您需要将另一个参数传递到
Frame.\uuuuuuu init\uuuuuuuuuuuuuuuuuu。请参见文档中的示例:
File "root.py", line 27, in load_file
    self.im = Image(filename=fname, resolution=200)
TypeError: __init__() takes at least 2 arguments (1 given)