python - 没有名为 Appkit 的模块。如果我尝试在 pycharm 中安装它,它会一直说“错误:命令错误,退出状态 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
安装。这就是解释器抱怨它的原因。
您必须安装该软件包,有两种可能性:
在终端类型
pip install AppKit
在 PyCharm 中执行:Preferences -> Project Interpreter -> 点击“+” -> type
AppKit
-> Install Package
瞧,它现在应该可以工作了。
推荐阅读
- android - Chromium for Android:如何始终保持全屏模式
- image - 裁剪和旋转捕获的图片 Xamarin.Android 和 Xamarin.iOS
- google-cloud-platform - Kubernetes Engine 无法从非私有/GCR 存储库中提取映像
- tensorflow - 将 Darkflow tensorflow 模型移植到 Tensorflow Android 相机检测演示
- mongodb - MeteorJS 应用安全
- java - 实时自我监控 Java 进程的内存
- scala - AuthenticationException Neo4j Spark 流式传输
- angular - Angular 5 自动对焦
- java - SQLite 1:M 关系
- c# - 将 Umbraco IContent 转换为 JSON