ImportError:无法导入名称'混音器'

时间:2017-11-06 13:56:36

标签: python-3.x pygame

我试图导入Pygame.mixer,如下所示:

from tkinter import *
from pygame import mixer
root = Tk()

def noise():
    pygame.mixer.init()
    pygame.mixer.music.load('D:\Y13\Computer Science\HP Projects\noise.mp3')
    pygame.mixer.music.play()
    return

label1 = Label(root, text="Press the button to play a sound.").pack()
button = Button(root, text="Noise", command=noise).pack()

mainloop()

但是我收到以下错误消息:

Traceback (most recent call last):
  File "D:/Y13/Computer Science/HP Projects/soundboard.py", line 2, in <module>
    from pygame import mixer
ImportError: cannot import name 'mixer'

我该如何解决这个问题?

0 个答案:

没有答案