0

I have this very simple test code:

from playsound import playsound

playsound('alarmsound.wav')

alarmsound.wav is a file in the same directory. when I run it in a terminal, it works fine. But when I run it in VSCode, it blows up with the following message:

Traceback (most recent call last):
  File "c:/Users/Luca/Desktop/Python/own/playaudio.py", line 3, in <module>
    playsound('alarmsound.wav')
  File "C:\Users\Luca\AppData\Local\Programs\Python\Python38-32\lib\site-packages\playsound.py", line 35, in _playsoundWin
    winCommand('open "' + sound + '" alias', alias)
  File "C:\Users\Luca\AppData\Local\Programs\Python\Python38-32\lib\site-packages\playsound.py", line 31, in winCommand
    raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException:
    Error 275 for command:
        open "alarmsound.wav" alias playsound_0.7197283376226026
    Cannot find the specified file.  Make sure the path and filename are correct.

It used to work in vscode before, now suddenly it blows up. what could be wrong?

4

1 回答 1

0

确保您实际上是从声音文件所在的目录运行该文件。

就我而言,它是从包含该文件的文件夹的父目录运行 Python .wav

于 2020-06-04T15:48:03.350 回答