Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
即使在pip安装playsound之后,在vscode(python)中导入playsound模块时也会出错_Python_Visual Studio Code_Playsound Module - Fatal编程技术网

即使在pip安装playsound之后,在vscode(python)中导入playsound模块时也会出错

即使在pip安装playsound之后,在vscode(python)中导入playsound模块时也会出错,python,visual-studio-code,playsound-module,Python,Visual Studio Code,Playsound Module,代码如下: 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 = ala

代码如下:

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
这是一个错误:

从playsound导入playsound
ModuleNotFoundError:没有名为“playsound”的模块同意Sayse的说法。就好像您尚未在所使用的环境中安装“playsound”软件包一样

使用这些命令进行检查:

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

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

您正在不同的python环境中运行代码并安装playsound