Python播放声音命令错误261:驱动程序无法识别指定的命令

4jb9z9bj  于 2023-01-08  发布在  Python
关注(0)|答案(4)|浏览(656)

请帮助解决此错误:

>>> 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.
8aqjt8rx

8aqjt8rx1#

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

tsm1rwdh

tsm1rwdh2#

用途

pip install playsound==1.2.2

效果很好。

>>> from playsound import playsound

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

注意:-请避免使用“播放声音==1.3.0”
将生成如下错误:“驱动程序无法识别指定的命令参数。”

yx2lnoni

yx2lnoni3#

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

oaxa6hgo

oaxa6hgo4#

我在最新版本中遇到了同样的问题
降级到1.2对我来说很有效。
pip安装播放声音==1.2.2

相关问题