我正在尝试使用pygame和tkinter编写一个带有按钮的音乐软件,当您单击它们时,它会触发一个音乐文件,当我第一次创建它时,一切都很好并且可以正常工作。但是第二天,我登录到计算机,该程序无法正常工作。这是我的代码:
#other purposes
from tkinter import *
import random
import pygame
import time
root = Tk()
#music i chose
label_playing_1 = Label(root, text="Currently playing: \n Dua Lipa - Don't start now")
#function that runs the music
music_file_1 = 'song1.mp3'
def play_music():
label_clear()
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(music_file_1)
pygame.mixer.music.play()
button_music_1 = Button(root, text="Dua Lipa - Don't start now", command=play_music)
button_music_1.pack()
root.mainloop()
我在命令提示符下也执行了命令pip3 install pygame
。以及将文件下载为mp3。
我在控制台中收到此错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "c:/Users/User/Downloads/kisha music/music.py", line 142, in play_music
pygame.mixer.music.load('song1.mp3')
pygame.error: Failed loading libmpg123.dll: Attempt to access invalid address
我正在使用Windows btw