1

I can't get playsound to work, it instead gives me TypeError: can only concatenate str (not "bytes") to str. Please bear with me here, I'm a first timer here and not very good with python.

The error:

Exception has occurred: TypeError
can only concatenate str (not "bytes") to str
  File "C:\Users\memer\Desktop\Internecion\test.py", line 2, in <module>
    playsound(r'C:/Users/memer/Desktop/Internecion/ICONTHEME.mp3')
TypeError: can only concatenate str (not "bytes") to str

Dunno why I'm getting this. Tried all three of these, none worked. All net the same error.

from playsound import playsound
playsound('C:\\Users\\memer\\Desktop\\Internecion\\ICONTHEME.mp3')
from playsound import playsound
playsound(r'C:\Users\memer\Desktop\Internecion\ICONTHEME.mp3')
from playsound import playsound
playsound(r'C:/Users/memer/Desktop/Internecion/ICONTHEME.mp3')

Full traceback:

Traceback (most recent call last):
  File "C:\Users\memer\Desktop\Internecion\test.py", line 2, in <module>
    playsound(r'C:\Users\memer\Desktop\Internecion\ICONTHEME.mp3')
  File "C:\Users\memer\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\playsound.py", line 34, in _playsoundWin
    winCommand('open "' + sound + '" alias', alias)
  File "C:\Users\memer\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\playsound.py", line 27, in winCommand
    exceptionMessage = ('\n    Error ' + str(errorCode) + ' for command:'
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: can only concatenate str (not "bytes") to str
Luke Woodward
  • 63,336
  • 16
  • 89
  • 104

1 Answers1

0

Based on the line numbers, this appears to be an old version of the package (perhaps this one) which targeted Python 2 and (as was common for that version) did not handle character and byte strings in a consistent fashion.

Davis Herring
  • 36,443
  • 4
  • 48
  • 76