无法运行播放通过cx_Freeze编译的OGG文件的Pygame脚本 [英] Can't run Pygame script that plays a OGG file compiled through cx_Freeze

查看:81
本文介绍了无法运行播放通过cx_Freeze编译的OGG文件的Pygame脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译以下脚本时:

# play.py

import os, re
import pygame.mixer

pygame.mixer.init(11025)
pygame.mixer.music.load('song.ogg')
pygame.mixer.music.play(-1)

os.system("PAUSE")

使用以下 setup.py

from cx_Freeze import setup, Executable
exe = Executable(
script="play.py",
)

setup(
    executables = [exe]
    )

通过:

python setup.py build

执行 play.exe 给我以下错误:

Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
    exec(code, m.__dict__)
  File "play.py", line 7, in <module>
pygame.error: Couldn't open 'song.ogg'

脚本正常运行在编译之前,是的,我确实将 song.ogg 放在 exe 的目录中。顺便说一句, song.ogg 正常工作,我已经检查过了。有什么想法吗?

The script works fine before compiling and yes, I did put song.ogg in exe's directory. By the way song.ogg works fine, I already checked. Any ideas?

P.S。如果将其更改为 song.wav ,则可以正常使用,但WAV文件太大,无法使用。 MP3也无法正常工作。

P.S. If I change it to song.wav it works fine, but WAV files are way too large for me to use. Also MP3 doesn't work as it should.

推荐答案

通过进程浏览器我发现我需要复制 libogg.dll libvorbis.dll libvorbisfile.dll Python33\Lib\site-packages\pygame 转到冻结程序的目录。

Through Process Explorer I was able to find out I needed to copy libogg.dll, libvorbis.dll and libvorbisfile.dll from Python33\Lib\site-packages\pygame to my frozen program's directory.

这篇关于无法运行播放通过cx_Freeze编译的OGG文件的Pygame脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆