gpt4 book ai didi

python - cx_卡住 : cannot find file/directory icon. gif

转载 作者:太空宇宙 更新时间:2023-11-03 15:12:08 25 4
gpt4 key购买 nike

我正在将 cx_Freeze 与 Python 3.4.1 一起使用,我正在尝试从我的一个 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

如有任何帮助,我们将不胜感激。

最佳答案

重新发布作为答案:

相对路径名是相对于您运行的位置找到的,而不是 setup.py 脚本所在的位置。在终端使用cd切换到setup.py所在目录,然后运行python setup.py build

如果出于某种原因这不可行,您可以在 setup.py 脚本中使用 os.chdir()

关于python - cx_卡住 : cannot find file/directory icon. gif,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25138628/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com