4

请帮助解决此错误:

>>> from playsound import playsound
>>> playsound('C:\\Users\\Rohit\\Desktop\\Python\\file.mp3')

终端结果:

PS C:\Users\Rohit\Desktop\Python> & C:/Users/Rohit/AppData/Local/Programs/Python/Python38/python.exe c:/Users/Rohit/Desktop/Python/2Python.py

    Error 261 for command:

        open "C:\Users\Rohit\Desktop\Python\file.mp3"

    The driver cannot recognize the specified command.

    Error 261 for command:

        close "C:\Users\Rohit\Desktop\Python\file.mp3"

    The driver cannot recognize the specified command.

Failed to close the file:

 "C:\Users\Rohit\Desktop\Python\file.mp3"

Traceback (most recent call last):
  File "c:/Users/Rohit/Desktop/Python/2Python.py", line 3, in <module>
    playsound('C:\\Users\\Rohit\\Desktop\\Python\\file.mp3')
  File "C:\Users\Rohit\AppData\Local\Programs\Python\Python38\lib\site-packages\playsound.py", line 72, in _playsoundWin
   winCommand(u'open {}'.format(sound)) 
File "C:\Users\Rohit\AppData\Local\Programs\Python\Python38\lib\site-packages\playsound.py", line 64, in winCommand
    raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException:
  
Error 261 for command:
        
        open "C:\Users\Rohit\Desktop\Python\file.mp3"
     
   The driver cannot recognize the specified command.
4

3 回答 3

13

我使用的是 playsound 版本 = 1.3.0 | 在这个版本中,我发现了和你一样的错误。对于解决方案,您必须降级您的 playsound 版本。为此,您必须先通过此代码卸载您的 playsound 模块...pip uninstall playsound然后按“y”继续。然后通过这个命令安装旧的纯版本playsound...pip install playsound==1.2.2然后尝试执行你的代码。它会工作。

于 2021-09-03T11:52:24.083 回答
7

利用

pip install playsound==1.2.2 

效果很好。

>>> from playsound import playsound

>>> playsound('C:\\Users\hvars\Downloads\\tiktok.mp3')

注意:- 请避免使用 ''' playsound==1.3.0 '''

它会产生这样的错误'''驱动程序无法识别指定的命令参数。'''

于 2021-10-03T13:16:30.133 回答
1

打开终端,只需卸载playsound pip uninstall playsound ,然后安装更稳定的playsound版本, pip install playsound==1.2.2 这个问题必须解决。

于 2021-10-07T19:42:46.163 回答