我在Python 3.4.1中使用cx_Freeze,我正在尝试从我的一个Python程序创建一个应用程序。不幸的是,我在运行setup.py build之后遇到了这个错误:
cx_Freeze.freezer.ConfigError: cannot find file/directory named icon.gif
这是我的设置文件:
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32" : base = "Win32GUI"
opts = {"include_files": ['icon.gif', "EndingsPerfect.txt", "EndingsPPP.txt", "LatinEnglishPronouns.txt", "1stConj/", "2ndConj/", "3rdConj/", "4thConj/"], "includes": ["re"]}
setup(name = "LT",
version = "1.0",
description = "Latin verbs",
author = "Laurence vS",
options = {"build_exe": opts},
executables = [Executable("latintranslatewithguipyw.pyw", base = base)])
此错误让我感到困惑,因为icon.gif
文件与安装文件位于同一文件夹中。
以下是完整的追溯:
C:\Users\Laurence> python "C:\Users\Laurence\Dropbox\Python programs\GUIs\latintr
anslatewithgui\setup.py" build
running build
running build_exe
Traceback (most recent call last):
File "C:\Users\Laurence\Dropbox\Python programs\GUIs\latintranslatewithgui\set
up.py", line 14, in <module>
executables = [Executable("latintranslatewithguipyw.pyw", base = base)])
File "C:\Python34\lib\site-packages\cx_Freeze\dist.py", line 362, in setup
distutils.core.setup(**attrs)
File "C:\Python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\distutils\command\build.py", line 126, in run
self.run_command(cmd_name)
File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\site-packages\cx_Freeze\dist.py", line 231, in run
metadata = metadata)
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 108, in __init
__
self._VerifyConfiguration()
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 498, in _Verif
yConfiguration
sourceFileName)
cx_Freeze.freezer.ConfigError: cannot find file/directory named icon.gif
任何帮助都将不胜感激。
答案 0 :(得分:4)
重新作为答案:
相对于您运行的位置,而不是setup.py脚本的位置,找到相对路径名。在终端中使用cd
切换到setup.py所在的目录,然后运行python setup.py build
。
如果由于某种原因这不可行,您可以在setup.py脚本中使用os.chdir()
。