0

所以,这是我的问题。

我正在使用 Ubuntu 12.10 在 Pygame 和 Python 3.3 中制作游戏。美好的。我会将一堆 Python 脚本捆绑到一个可执行文件中,然后分发它。也很好。我将使用 cx_freeze,因为因为我使用的是 Python 3,所以我没有其他选择。

这就是我的问题所在。我用谷歌搜索过,但没有看到类似的东西。我setup.py的如下:

from cx_Freeze import setup, Executable
import sys

includes = ['sys', 'pygame.display', 'pygame.event', 'pygame.mixer', 'core', 'game']

build_options = {
                 'optimize' : 2,
                 'compressed': True,
                 'packages': ['pygame', 'core', 'game'],
                 'includes': includes,
                 'path': sys.path + ['core', 'game'],
                 }

executable = Executable('__init__.py',
                        copyDependentFiles=True,
                        targetDir='dist',
                        )

setup(name='Invasodado',
      version='0.8',
      description='wowza!',
      options = {'build_exe': build_options},
      executables=[executable])

__init__.py的如下:

from sys import argv

import pygame.display
import pygame.event
import pygame.mixer

pygame.mixer.init()
pygame.display.init()
pygame.font.init()

from core import gsm

#Omitted for brevity

我的其余代码(包括完整的__init__.py)可以在https://github.com/CorundumGames/Invasodado找到,以防万一。

I get a long-ass stack trace, which can be found here http://pastebin.com/Aej05wGE . The last 10 lines of it is this;

  File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/finder.py", line 421, in _RunHook
    method(self, *args)
  File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/hooks.py", line 454, in load_scipy
    finder.IncludePackage("scipy.lib")
  File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/finder.py", line 536, in IncludePackage
    self._ImportAllSubModules(module, deferredImports)
  File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/finder.py", line 211, in _ImportAllSubModules
    recursive)
  File "/usr/local/lib/python3.3/dist-packages/cx_Freeze/finder.py", line 209, in _ImportAllSubModules
    if subModule.path and recursive:
AttributeError: 'NoneType' object has no attribute 'path'

In case it's relevant, I'm using Pydev and Eclipse. Now, the last line stands out because Googling it reveals nothing. I have no idea where subModule could have become None, and I can't easily check because cx_freeze has shit documentation.

I've never really used cx_freeze or distutils before, so I don't know what the hell I'm doing! Any help would be greatly appreciated.

4

1 回答 1

1

Having dug into this, it's a bug in cx_Freeze, that can only hit when you have more than one Python version since PEP 3149 installed - i.e. it wouldn't have come up before 3.3.

I've filed a bug report for it: https://bitbucket.org/anthony_tuininga/cx_freeze/issue/22/error-when-scanning-for-modules-with-a

In the mean time, you can probably avoid the problem by using Python 3.2 for now, because that's the default in Ubuntu 12.10. Python 3.3 will be the default in 13.04.

于 2013-03-07T18:35:14.543 回答