cx_freeze错误时,我试图包括图像 [英] cx_freeze error when I try to include images

查看:322
本文介绍了cx_freeze错误时,我试图包括图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试 build 我的游戏编译器时会出现错误:

  Traceback(最近一次调用):
文件gamecomp.py,第22行,在< module>
executables = [exe])
文件C:\Python33\lib\site-packages\cx_Freeze\dist.py,第365行,在安装
distutils。 core.setup(** attrs)
文件C:\Python33\lib\distutils\core.py,第148行,在安装
dist.run_commands()
文件C:\Python33\lib\distutils\dist.py,第929行,在run_commands中
self.run_command(cmd)
文件C:\Python33\lib\\ \\ distutils \dist.py,行948,在run_command
cmd_obj.run()
文件C:\Python33\lib\distutils\command\build.py line 126,in run
self.run_command(cmd_name)
在run_command
self中的文件C:\Python33\lib\distutils\cmd.py,第313行。 distribution.run_command(command)
文件C:\Python33\lib\distutils\dist.py,第948行,在run_command中
cmd_obj.run()
文件 C:\Python33\lib\site-packages\cx_Freeze\dist.py,第234行,在运行
metadata = metadata)
文件C:\Python33\lib \site-packages\cx_Freeze\freezer.py,第104行,在__init
__
self.includeFiles = self._ProcessPathSpecs(includeFiles)
文件C:\Python33 \ lib \site-packages\cx_Freeze\freezer.py,行384,在_Proce
ssPathSpecs
raise ConfigError(包含文件的目标路径可能不是
cx_Freeze .freezer.ConfigError:include文件的目标路径可能不是absolu
te路径

我的编译器是:

  import sys 
从cx_Freeze导入安装程序,可执行文件

build_exe_options = {packages:[os],excludes:[tkinter],include_files:[C:\Documents and Settings\boot_1.bmp,C:\Documents and Settings \\ \\boot_2.bmp,'C:\Documents和Settings\boot_3.bmp','C:\Documents和Settings\boot_4.bmp','C:\Documents和Settings\fish1.bmp' ,'C:\Documents和Settings\fish2.bmp','C:\Documents和Settings\fish3.bmp','C:\Documents和Settings\fish4.bmp','C: \\ Documents and Settings\goldenfish_1.bmp','C:\Documents and Settings\goldenfish_2.bmp']}

base = None
如果sys.platform ==win32 :
base =Win32GUI

exe =可执行文件(
script =game.py,
base = base


setup(name =Game name,
version =1.0,
description =My GUI application!,
options = {build_exe:build_exe_options} ,
executables = [exe])

如果我不使用 include_files 我可以编译游戏没有任何错误,但其他人不能玩游戏。
我如何编译我的游戏没有错误/修复错误?

解决方案



我必须写:boot_1.bmp而不是C:\Documents和Settings \\



我还需要在游戏代码中更改它。


When I try to build my game compiler I get error:

Traceback (most recent call last):
  File "gamecomp.py", line 22, in <module>
    executables = [exe])
  File "C:\Python33\lib\site-packages\cx_Freeze\dist.py", line 365, in setup
    distutils.core.setup(**attrs)
  File "C:\Python33\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Python33\lib\distutils\dist.py", line 929, in run_commands
    self.run_command(cmd)
  File "C:\Python33\lib\distutils\dist.py", line 948, in run_command
    cmd_obj.run()
  File "C:\Python33\lib\distutils\command\build.py", line 126, in run
    self.run_command(cmd_name)
  File "C:\Python33\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Python33\lib\distutils\dist.py", line 948, in run_command
    cmd_obj.run()
  File "C:\Python33\lib\site-packages\cx_Freeze\dist.py", line 234, in run
    metadata = metadata)
  File "C:\Python33\lib\site-packages\cx_Freeze\freezer.py", line 104, in __init
__
    self.includeFiles = self._ProcessPathSpecs(includeFiles)
  File "C:\Python33\lib\site-packages\cx_Freeze\freezer.py", line 384, in _Proce
ssPathSpecs
    raise ConfigError("target path for include file may not be "
cx_Freeze.freezer.ConfigError: target path for include file may not be an absolu
te path

My compiler is:

import sys
from cx_Freeze import setup, Executable

build_exe_options = {"packages": ["os"], "excludes": ["tkinter"], "include_files":["C:\Documents and Settings\boot_1.bmp", "C:\Documents and Settings\boot_2.bmp", 'C:\Documents and Settings\boot_3.bmp', 'C:\Documents and Settings\boot_4.bmp', 'C:\Documents and Settings\fish1.bmp', 'C:\Documents and Settings\fish2.bmp', 'C:\Documents and Settings\fish3.bmp', 'C:\Documents and Settings\fish4.bmp', 'C:\Documents and Settings\goldenfish_1.bmp', 'C:\Documents and Settings\goldenfish_2.bmp']}

base = None
if sys.platform == "win32":
    base = "Win32GUI"

exe=Executable(
     script="game.py",
     base=base
     )

setup(  name = "Game name",
        version = "1.0",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [exe])

If I don't use include_files I can compile the game without any errors, but others can't play the game. How can I compile my game without errors / fix errors?

解决方案

I get it now.

I have to write: "boot_1.bmp" instead "C:\Documents and Settings\boot_1.bmp" and so for all other pictures.

I also have to change it in the game code.

这篇关于cx_freeze错误时,我试图包括图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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