使用playsound
模块的简单工作代码在运行cx_freeze
生成的exe时发出以下错误,而实际的python代码运行时没有任何错误。
waqas@waqas-pc:~/sound$ ./build/exe.linux-x86_64-2.7/sound.py
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/__startup__.py", line 14, in run
module.run()
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/Console.py", line 26, in run
exec(code, m.__dict__)
File "sound.py", line 20, in <module>
play_tune(tune)
File "sound.py", line 14, in play_tune
playsound.playsound(tune,True)
File "/usr/local/lib/python2.7/dist-packages/playsound.py", line 91, in _playsoundNix
import gi
File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 42, in <module>
from . import _gi
ImportError: No module named _error
如何解决此问题。
setup.py
的{{1}}文件如下所示:
cx_freeze
这是我试图运行的代码段。
import sys
from cx_Freeze import setup, Executable
packages = ["playsound", "os", "time", "multiprocessing"]
Sound = Executable(
script = "sound.py",
targetName = "sound.py",
)
setup(name = "sound" ,
version = "0.1" ,
options = {"build_exe": {"packages": packages}},
description = "" ,
executables = [Sound]
)
答案 0 :(得分:0)
我终于解决了它。我在"gi"
中向packages
添加了setup.py
。不明白为什么我必须添加这个额外的包,但为我工作。