4

I am making a simple program for my entertainment using the playsound module. Here's my code:

from playsound import playsound

print("please wait")
playsound("scan.wav")

and the error messsage:

Traceback (most recent call last):
  File "D:\Programi\python\lab\lab.py", line 9, in <module>
    playsound("scan.wav")
  File "C:\Users\ONT Studios\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\playsound.py", line 35, in _playsoundWin
    winCommand('open "' + sound + '" alias', alias)
  File "C:\Users\ONT Studios\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\playsound.py", line 31, in winCommand
    raise PlaysoundException(exceptionMessage)
playsound.PlaysoundException: 
    Error 266 for command:
        open "scan.wav" alias playsound_0.98994089730741
    Unknown problem while loading the specified device driver.

This is my path: D:\Programi\python\lab with files: lab.py, scan.mp3, and scan.wav.

I tried this, but with no success.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61

1 Answers1

1

I was facing the same issue today and I was able to fix it in one way. It is probably a bug but you can get around it. So basically when importing several modules in a row, this will create the error. What I did is import first the playsound module then play one sound and print a bunch of random stuff then import the rest of the modules. This fixed my issue.

import mouse
from playsound import playsound

playsound('D:/rakkiz.mp3')
print("\n")
print("\n")
print("\n")
print("\n")

import re
import pywinauto
import time
import keyboard
Ideocrat
  • 11
  • 1
  • If you're not importing any other modules and still have this issue, then I'm afraid the solution proposed is not compatible with your case. – Ideocrat May 03 '21 at 13:15