P's*_*sao 4 python pygame py2exe
我制作了一个带有pygame代码的MP3播放器:
from Tkinter import *
import pygame
import glob
import tkFont
songs=[]
for x in glob.glob('C:\WhaleTunes\Downloaded/*mp3'):
songs.append(x)
Admin=Tk()
num=0
plpa=-1
songas=Label(Admin,text='',bg='red')
songas.place(relx=0.0,rely=0.7)
def play(number):
pygame.mixer.music.unpause()
pygame.mixer.music.load(songs[number])
pygame.mixer.music.play()
songas.configure(text=songs[number])
def pause():
pygame.mixer.music.pause()
def Pre():
global num
if num == 0:
z = len(songs)
num=z
num+=1
num-=1
play(num)
def Next():
global num
num+=1
play(num)
#init pygame mixer
pygame.mixer.init()
#atach all buttons & labels
fons=tkFont.Font(family="bold", size=40)
fon=tkFont.Font(family="Helvetica", size=20)
tit=Label(Admin,text='Mp3 Player',font=fons,fg='grey',bg='red')
tit.place(relx=0.2,rely=0.0)
playnpause=Button(Admin,text='Play',command=lambda:play(num),fg='yellow',bg='red',font=fon)
playnpause.place(relx=0.0,rely=0.4)
last=Button(Admin,text='Previous',command=Pre,fg='yellow',bg='red',font=fon)
last.place(relx=0.2,rely=0.4)
first=Button(Admin,text='Next',command=Next,fg='yellow',bg='red',font=fon)
first.place(relx=0.5,rely=0.4)
pauses=Button(Admin,text='Pause',command=pause,fg='yellow',bg='red',font=fon)
pauses.place(relx=0.7,rely=0.4)
Admin.minsize(width=500, height=200)
Admin.maxsize(width=500, height=200)
Admin.configure(bg='red')
Admin.mainloop()
Run Code Online (Sandbox Code Playgroud)
我试着用这段代码把它放到一个exe中:
from distutils.core import setup
import py2exe
setup(console=['mp3player.py'])
Run Code Online (Sandbox Code Playgroud)
当我运行mp3player.exe时,我收到一堆导入错误:
C:\Users\P'sao\Downloads\dist\mp3player.exe:2: RuntimeWarning: import display: N
o module named _view
(ImportError: No module named _view)
C:\Users\P'sao\Downloads\dist\mp3player.exe:2: RuntimeWarning: import draw: No m
odule named _view
(ImportError: No module named _view)
C:\Users\P'sao\Downloads\dist\mp3player.exe:2: RuntimeWarning: import image: No
module named _view
(ImportError: No module named _view)
C:\Users\P'sao\Downloads\dist\mp3player.exe:2: RuntimeWarning: import pixelcopy:
No module named _view
(ImportError: No module named _view)
C:\Users\P'sao\Downloads\dist\mp3player.exe:2: RuntimeWarning: import transform:
No module named _view
(ImportError: No module named _view)
Run Code Online (Sandbox Code Playgroud)
有人知道怎么修这个东西吗?
当我编译所有内容时,我收到此错误:
The following modules appear to be missing
['AppKit', 'Foundation', 'Numeric', 'OpenGL.GL', '_scproxy', 'copyreg', 'dummy.P
rocess', 'numpy', 'pkg_resources', 'queue', 'winreg', 'pygame.sdlmain_osx']
Run Code Online (Sandbox Code Playgroud)
解决方案是添加import pygame._view到主源文件的顶部.任何包装商都应该在那之后工作.我使用cx_Freeze,py2exe和pyInstaller遇到了这个问题.在尝试打包pygame程序时,这是影响许多exe包装程序的严重错误.
| 归档时间: |
|
| 查看次数: |
6102 次 |
| 最近记录: |