python - 使用 playsound 模块 python 错误 259 无法播放声音文件
问题描述
from playsound import playsound
playsound("1.mp3")
上面使用 playsound 模块的代码会导致以下错误。如何解决?
Error 259 for command:
play 1.mp3 wait
The driver cannot recognize the specified command parameter.
Error 263 for command:
close 1.mp3
The specified device is not open or is not recognized by MCI.
Failed to close the file: 1.mp3
Traceback (most recent call last):
File "C:\Users\itsra\OneDrive\Desktop\Python\test.py", line 4, in <module>
playsound("1.mp3")
File "C:\Users\itsra\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\playsound.py", line 73, in _playsoundWin
winCommand(u'play {}{}'.format(sound, ' wait' if block else ''))
File "C:\Users\itsra\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\playsound.py", line 64, in winCommand
raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException:
Error 259 for command:
play 1.mp3 wait
The driver cannot recognize the specified command parameter.
解决方案
我也遇到了同样的问题。尝试降级 playsound 版本。利用
pip install playsound==1.2.2
这解决了它。
推荐阅读
- xamarin - 动态加载xml控件并共享UI控件
- python - Tkinter 代码未显示按钮 (v:3.6)
- python - 求解隐式函数并传入三个参数
- android - FireStore 批量写入不同的集合
- node.js - 节点 Winston 记录器:着色不起作用
- php - mysql PDO 更新哪里 id=?
- r - 为什么 tmap 的渲染速度比 ggplot2 快 80 倍?[在 R 中使用 ggplot2::geom_sf() 绘制 shapefile,在 macOS 上使用 XQuartz/X11 图形设备]
- angular - Angular 6:计算列表的总和(可观察)
- ms-access - Ms Access,按特定日期分组
- swift - UIImagePicker 无法正常运行