没有名为 Appkit 的模块。如果我尝试在pycharm中安装它,它一直说"ERROR: Command errored out with exit status 1:"



我正在使用pycharm,似乎不知道如何修复这个错误。

Exception in Tkinter callback
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tkinter/__init__.py", line 1883, in __call__
return self.func(*args)
File "/Users/syedrishad/PycharmProjects/OpenCVPython/venv/Text To Speech.py", line 44, in Text_to_speech
playsound('DataFlair.mp3')
File "/Users/syedrishad/OpenCVPython/lib/python3.8/site-packages/playsound.py", line 55, in _playsoundOSX
from AppKit     import NSSound
ModuleNotFoundError: No module named 'AppKit'

这是代码:

## import libraries
from tkinter import *
from gtts import gTTS
from playsound import playsound

################### Initialized window####################
root = Tk()
root.geometry('350x300')
root.resizable(0,0)
root.config(bg = 'ghost white')
root.title('DataFlair - TEXT_TO_SPEECH')

##heading
Label(root, text = 'TEXT_TO_SPEECH' , font='arial 20 bold' , bg ='white smoke').pack()
Label(root, text ='DataFlair' , font ='arial 15 bold', bg = 'white smoke').pack(side = BOTTOM)


#label
Label(root, text ='Enter Text', font ='arial 15 bold', bg ='white smoke').place(x=20,y=60)

##text variable
Msg = StringVar()

#Entry
entry_field = Entry(root,textvariable =Msg, width ='50')
entry_field.place(x=20 , y=100)

###################define function##############################
def Text_to_speech():
Message = entry_field.get()
speech = gTTS(text = Message)
speech.save('DataFlair.mp3')
playsound('DataFlair.mp3')
def Exit():
root.destroy()
def Reset():
Msg.set("")
#Button
Button(root, text = "PLAY" , font = 'arial 15 bold', command = Text_to_speech, width =4).place(x=25, y=140)
Button(root,text = 'EXIT',font = 'arial 15 bold' , command = Exit, bg = 'OrangeRed1').place(x=100,y=140)
Button(root, text = 'RESET', font='arial 15 bold', command = Reset).place(x=175 , y =140)

#infinite loop to run program
root.mainloop()

我对此感到非常困惑,其他人的解决方案对我不起作用。任何帮助都将不胜感激。我已经试着解决这个问题一个星期了。哦,这不是我的密码。我正在参加一个教程,这是我一直在做的项目之一。

您没有安装AppKit。这就是为什么翻译抱怨它。

你必须安装软件包,有两种可能性:

  1. In终端类型pip install AppKit

  2. 在PyCharm中:首选项->项目口译员->点击"+&quot->类型AppKit->安装包

Et瞧,它现在应该可以工作了。

相关内容

最新更新