所以,這是我的問題。Python 3.3 cx_freeze奇怪的錯誤:'NoneType'對象沒有屬性'路徑'
我正在使用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可以發現,如果它是相關的。
我得到一個長屁股堆棧跟蹤,可以在這裏找到http://pastebin.com/Aej05wGE。最後10行是這個;
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'
如果相關,我使用Pydev和Eclipse。現在,最後一行突出顯示,因爲Google搜索沒有任何結果。我不知道subModule
可能變成None
,我不能輕易檢查,因爲cx_freeze有狗屎文檔。
我從來沒有真正使用過cx_freeze或distutils,所以我不知道我到底在做什麼!任何幫助將不勝感激。
第一次看:調用你的啓動腳本'__init __。py'有點奇怪。通常你有一個名爲'invasididado.py'的腳本(或其他),它導入一個包並從中調用一個函數。這可能會在cx_Freeze中遇到未經檢驗的角落案例。 – 2013-03-07 13:13:51
(無法在Python 3.2,Ubuntu 12.10中使用當前主cx_Freeze重現) – 2013-03-07 13:20:38