Reputation: 31
Going to keep this short and sweet. I am trying to play a song using pygame's mixer. I have the song titles in a dictionary and are accessing the name of the stored file using this. When I choose the song to play I get this error.
Traceback (most recent call last):
File "c:\Users\me\Documents\Bella\Music.py", line 50, in <module>
song_look_up_by_artist("artist1", thisdict)
File "c:\Users\me\Documents\Bella\Music.py",line 37, in song_look_up_by_artist
mixer.music.load(toplay)
pygame.error: Failed loading libmpg123-0.dll: The specified module could not be found.
I have found a couple of posts that addressed the issue. They all said close your IDE and restart your computer. I have tried this and nothing. I also found the file that supposedly cannot be found but libmpg123-0.dll is in the pygame's folder. The python file and the .mp3 file are both inside the same folder. I have also put libmpg123-0.dll there as well. I am also using python 3.8.6, windows 10, VScode as my IDE. I don't know what is the real problem. Here is my code if that helps as well.
I found the libmpg123-0.dll file in :\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages
from pygame import mixer
import pygame
thisdict = {
("artist1", "song1"): 'KDA.mp3',
("artist3", "song1"): 'Nanners.mp3',
("artist1", "song2"): 'ATL.mp3',
}
mixer.init()
#mixer.music.load("C:\Users\Connor Ferwerda\Downloads\\")
#mixer.music.play()
def song_look_up_by_artist(artist, thisdict):
#get list of songs that match artist
mixer.init()
song_list = []
for x in thisdict:
if x[0] == artist:
song_list.append(x[1])
#lets user pick if they wanna play a song
answer = input("Would you like to play a song by " + artist + "? " )
print("\n")
if answer == "quit":
print("ok")
elif answer == "yes":
print("Here is there list of songs: ")
print(song_list)
#they pick which song
answer = input("Which song? ")
for song in song_list:
if answer == song:
toplay = thisdict[(artist, answer)]
mixer.music.load(toplay)
mixer.music.play()
while mixer.music.get_busy():
print("playing...")
pygame.time.Clock().tick(10)
elif song == song_list[-1]:
print("that doensn't match")
break
song_look_up_by_artist("artist1", thisdict)
Thank you!
Upvotes: 2
Views: 3040
Reputation: 31
The path file of the interpreter was wrong. Fixed it with that.
Upvotes: 1
Reputation: 27557
Try uninstalling pygame
:
pip uninstall pygame
and then reinstalling the latest version of it:
pip install pygame
Upvotes: 1