Python Playsound Error 261 for command: The driver cannot recognize the specified command
Asked Answered
S

4

14

Please help to solve this error:

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

Result from Terminal:

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.
Sophister answered 8/8, 2021 at 20:20 Comment(3)
Please take the tour and carefully read through the help center to learn more about the site, including what is on-topic and what is not, as well as How to Ask. Please also follow the question checklist.Corkboard
"I don't know how to ask questions on StackOverflow" Then you should read How to Ask. Anyway, Stack Overflow is not tech support. If you think the problem is in your code, you need to show us the code. If you think the problem is with the library, then you need to try using the issue tracker for that project instead. If you think the problem is your computer's configuration, then you should try superuser.com. But in every case you should start by searching the Internet and reading the documentation.Orthodoxy
Ok Sir, I try to resolve it. Thank You.Sophister
M
26

I was using playsound version = 1.3.0 | With this version i have found same error like you. For solution you have to downgrade your playsound version. For this you have to first uninstall your playsound module by this code...pip uninstall playsound then press "y" to proceed . Then install the old and pure version of playsound by this command... pip install playsound==1.2.2 and then try to execute your code.It will work.

Menses answered 3/9, 2021 at 11:52 Comment(1)
This works for me! I wonder what they did in 1.3 to make it error out like that...Failsafe
K
17

Use

pip install playsound==1.2.2 

it works great.

>>> from playsound import playsound

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

Note:- plz avoid using ''' playsound==1.3.0 '''

It will generate error like this ''' The driver cannot recognize the specified command parameter. '''

Kezer answered 3/10, 2021 at 13:16 Comment(0)
L
3

Open the terminal and just uninstall playsound by pip uninstall playsound and then just install the more stable version of playsound pip install playsound==1.2.2 by this the problem must be solved.

Lens answered 7/10, 2021 at 19:42 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Rena
B
1

I had the same problem with the latest version. Downgrading to 1.2 worked for me:

pip install playsound==1.2.2
Blinker answered 7/1, 2023 at 16:47 Comment(1)
Thanks you for the amendment. It looks better now.Blinker

© 2022 - 2024 — McMap. All rights reserved.