【问题标题】:Trying to play a song through pygame but get a libmpg123-0.dll error尝试通过 pygame 播放歌曲但出现 libmpg123-0.dll 错误
【发布时间】:2020-11-12 18:04:34
【问题描述】:

要保持简短而甜蜜。我正在尝试使用 pygame 的混音器播放歌曲。我在字典中有歌曲标题,并且正在使用它访问存储文件的名称。当我选择要播放的歌曲时出现此错误。

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.

我找到了一些解决该问题的帖子。他们都说关闭你的IDE并重新启动你的电脑。我已经尝试过了,没有。我还发现了应该找不到的文件,但 libmpg123-0.dll 在 pygame 的文件夹中。 python 文件和 .mp3 文件都在同一个文件夹中。我也将 libmpg123-0.dll 放在那里。我还使用 python 3.8.6、windows 10、VScode 作为我的 IDE。我不知道真正的问题是什么。如果这也有帮助,这是我的代码。

我在 :\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages 中找到了 libmpg123-0.dll 文件

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)

谢谢!

【问题讨论】:

    标签: python pygame


    【解决方案1】:

    尝试卸载pygame

    pip uninstall pygame
    

    然后重新安装它的最新版本:

    pip install pygame
    

    【讨论】:

    • 我刚刚卸载并重新安装了pygame,但我仍然收到同样的错误。
    【解决方案2】:

    解释器的路径文件错误。修复它。

    【讨论】:

      猜你喜欢
      • 2021-06-23
      • 2012-05-30
      • 1970-01-01
      • 2013-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-14
      • 1970-01-01
      相关资源
      最近更新 更多