I'm using os.startfile code to run .mp3 file but there is an error:
my code is
os.system("Warning.mp3") but i get an error like this,
sh: Warning.mp3: command not found can you help me about starting mp3 file using os.startfile?
os.system() makes a call to the system shell to execute the argument you pass. Therefore you get an error message from the shell sh saying that Warning.mp3 is not a command. If you want it to play from shell execution you need to pass it a command which can play a file such as this such as mpg123 on ubuntu/debian (make sure its installed). To invoke this from python:
os.system("mpg123 Warning.mp3") See the documentation on the os.system() function for more details. https://docs.python.org/2/library/os.html#os.system
afplay which plays mp3 files. So replace mpg123 with that program and give it a shot. By the way you didn't specify what the application is for this, but this may not be the implementation. This will call an external function in the shell to play music, and playback will be controlled by that program, not python. I haven't used it myself, but theres a python package called playsound you might want to check out. pypi.python.org/pypi/playsound/1.2.1
os.startfileor are you instead usingos.systemas your post suggests?