-1

这是代码:

from datetime import datetime 
from playsound import playsound

alarm_time = input("Enter the time of alarm to be set:HH:MM:SS\n")
alarm_hour=alarm_time[0:2]
alarm_minute=alarm_time[3:5]
alarm_seconds=alarm_time[6:8]
alarm_period = alarm_time[9:11].upper()
print("Setting up alarm..")
while True:
    now = datetime.datetime.now()
    current_hour = now.strftime("%I")
    current_minute = now.strftime("%M")
    current_seconds = now.strftime("%S")
    current_period = now.strftime("%p")
    if(alarm_period==current_period):
        if(alarm_hour==current_hour):
            if(alarm_minute==current_minute):
                if(alarm_seconds==current_seconds):
                    print("Wake Up!")
                    playsound('audio.mp3')
                    break

这是错误:

from playsound import playsound
ModuleNotFoundError: No module named 'playsound'
4

1 回答 1

0

同意赛斯。就像您没有在您使用的环境中安装“playsound”包一样。

使用这些命令进行检查:

pip --version
get-command python(Powershell)
where python(cmd)

确保 pip 已将软件包安装到您将选择的环境中。

于 2021-05-26T14:33:25.457 回答