Grab the VLC Python module , vlc. That module offers plenty beyond that like pretty much anything the VLC media player can do , but that's the simplest and most effective means of playing one MP3. You could play with os. Full documentation and pre-prepared modules are available here. Current versions are Python 3 compatible. You could try using pydub to convert it to. Alternatively, use pygame , as mentioned in the other answer. Now you might need to make some slight changes to make it work. For example, if the player needs extra arguments or you don't need to specify the full path.
But this is a simple way of doing it. I had this problem and did not find any solution which I liked, so I created a python wrapper for mpg mpyg You would need to have mpg installed on your computer, and then do pip install mpyg So Far, pydub worked best for me. Modules like playsound will also do the job, But It has only one single feature. Learn more. Playing mp3 song on python Ask Question. Asked 6 years, 9 months ago. Active 10 days ago.
Viewed k times. I want to play my song mp3 from python, can you give me a simplest command to do that? The Mr. Totardo The Mr. Totardo 1 1 gold badge 7 7 silver badges 10 10 bronze badges. Check out pygame , and read this question on raspberrypi. Wah, dari Indonesia ya? Wah, from indonesia? Active Oldest Votes. Try this. It's simplistic, but probably not the best method. Installation is simple - pip install pygame. Tester out pygame's mixer and it seems to a lot less intrusive than pyglet's media player.
Probably because pyglet's player is also a video player, so if you don't need video it's a bit overkill! It's a shame pybass don't have python 3 support. That used to be the bomb. I will try in python3 but not be working for me any suggestion!! HarshitTrivedi what is the error you get? Or does the music simply not play? If so, make sure the mp3 is playable. If you're apprehensive about using this because you do not want a pygame window to pop up notice that there is no pygame.
Ben Ben 2, 1 1 gold badge 16 16 silver badges 31 31 bronze badges. PyPi version is out dated but the VLC wiki is a good alternative src - wiki. Compiling VLC from source with the vlc. Scatch that, the version on PyPI is a completely unrelated thing. The result of someone writing their own wrapper and not checking for a naming conflict with the original project and similar to the python-gnupg vs. No doubt there are others. I guess that's one thing java got right in order to guarantee different and unique names. Worked, but with a caveat.
It used play for a moment and end since this was the last line of my program. I had to put another line time. See also playsound pip install playsound import playsound playsound. Tony Tony 4 4 silver badges 12 12 bronze badges. This library has a history of problems on Linux, unfortunately: github. Works perfectly on windows. It's the simplest solution I found on windows. Popen ['mpg', '-q', path]. Michael Michael 5, 31 31 silver badges 55 55 bronze badges.
You are trying to play a. David David 6 6 silver badges 6 6 bronze badges. Wael Almadhoun Wael Almadhoun 2 2 silver badges 5 5 bronze badges. Awesome solution!
A simple solution: import webbrowser webbrowser. Cute, but what if the only browser is lynx or even if the others are available on the system, the user only has command line access? Thank you Michael, but how i can add "playlist" instead one file? Another quick and simple option I made the experience that python-audio-tools just runs with Python 2, not 3. Evinden Uzakta. Sagopa Kajmer - Uzun Yollara Devam. Sagopa Kajmer - Istakoz.
MilkyWay90 6 6 silver badges 20 20 bronze badges. The usage is pretty simple: from mpyg It is as simple as slicing the lists in python. So, When it comes to just playing, It is as shown as below. Appaji Chintimi Appaji Chintimi 5 5 bronze badges. Aprillion Akshay Udnur Akshay Udnur 7. This will not do anything unless the operating system executes audio files solely by entering the path and filename; most, if not all, systems do not do this. Also, use of os.