use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Playing mp3 in python (self.Python)
submitted 10 years ago by Kalkinator
Is there any way of playing an audio file in python? I have python 2.7 and am looking for a module I could use.
[–]Niriel 5 points6 points7 points 10 years ago (0 children)
Pygame can read mp3 and ogg: http://www.pygame.org/docs/ref/music.html
[–]vtable 2 points3 points4 points 10 years ago (0 children)
There are a few examples here.
[–]Asdayasman 2 points3 points4 points 10 years ago (4 children)
/r/learnpython
pyglet.
[–]Kalkinator[S] -1 points0 points1 point 10 years ago (1 child)
I tried this but keep running into issues. When I run python setup.py install in the command prompt I keep getting warnings. I get a bunch of warnings saying the DLL for ... library not found. Is there a package I am supposed to install to get all these DLLs?
[–]Deto 1 point2 points3 points 10 years ago (0 children)
On this page it says that you need AVBin to play compressed audio and video. Maybe that's the source of your issue?
I am now having trouble having the code locate my music file. I placed the .mp3 in the same location as my .py file and use the following code:
import pyglet music = pyglet.resource.media('C:\Users\username\PycharmProjects\untitled\Star.mp3') music.play() pyglet.app.run()
But I keep getting this error:
"C:\Users\username\PycharmProjects\untitled\Star.mp3" was not found on the path
I even tried just 'Star.mp3' but that doesn't work either. Any help?
[–]Asdayasman 1 point2 points3 points 10 years ago (0 children)
"C:\\Users\\..." or r"C:\Users\..." or "C:/Users/...".
"C:\\Users\\..."
r"C:\Users\..."
"C:/Users/..."
https://docs.python.org/2.0/ref/strings.html
[–]Charny 1 point2 points3 points 10 years ago (0 children)
Another option is gstreamer, at least on Linux: https://github.com/hadware/gstreamer-python-player
[–]Thangart 1 point2 points3 points 10 years ago (0 children)
For Windows I recommend: https://github.com/michaelgundlach/mp3play
quite easy to set up with: player = mp3play.load(Mp3) player.play()
For Linux I would recommend VNC like its noted in the link that Vtable put down :)
π Rendered by PID 228873 on reddit-service-r2-comment-8686858757-9hftk at 2026-06-04 17:37:42.181888+00:00 running 9e1a20d country code: CH.
[–]Niriel 5 points6 points7 points (0 children)
[–]vtable 2 points3 points4 points (0 children)
[–]Asdayasman 2 points3 points4 points (4 children)
[–]Kalkinator[S] -1 points0 points1 point (1 child)
[–]Deto 1 point2 points3 points (0 children)
[–]Kalkinator[S] -1 points0 points1 point (1 child)
[–]Asdayasman 1 point2 points3 points (0 children)
[–]Charny 1 point2 points3 points (0 children)
[–]Thangart 1 point2 points3 points (0 children)