我一直拼命地試圖將我的python pygame程序編譯爲獨立的可執行文件,以至於不存在。 PyInstaller無法在pygame中正常工作,Nuitka不會使獨立工作,並且cx_Freeze正在尋找最佳選擇。但是,當我使用我的setup.py
進行編譯時,它會生成一組文件,但main
可執行文件不會運行。cx_Freeze:「沒有名爲」編解碼器「的模塊」
我setup.py
是如下:
import sys
import cx_Freeze
executables = [cx_Freeze.Executable("main.py")]
images =["assets/images/1.png","assets/images/2.png","assets/images/3.png","assets/images/4.png","assets/images/5.png","assets/images/6.png","assets/images/7.png","assets/images/8.png","assets/images/tile.png","assets/images/mark.png","assets/images/mine.png","assets/images/overlay.png","assets/images/overlay_2.png","assets/images/background.png"]
cx_Freeze.setup(
name="Minesweeper",
options={"build_exe": {"packages":["pygame"],
"include_files":images}},
executables = executables
)
有由main.py
參考其他Python文件;這是否重要?
非常感謝
編輯: 按照要求,平臺是Linux操作系統(Ubuntu的14.04); python版本是3.4.3; cx_Freeze是cxfreeze 5.0,通過pip下載。確切的錯誤如下:
Fatal Python error: Py_Initialize: Unable to get locale encoding
Traceback (most recent call last):
File "usr/lib/python3.4/encodings/__init__.py", line 31, in <module>
ImportError: No module named 'codecs'
Aborted (core dumped)
什麼平臺?什麼版本的cx_Freeze?什麼版本的Python?你得到了什麼異常(和調用堆棧)?只要main.py使用常規導入語句導入其他Python文件,則應自動查找幷包含其他文件。 –
@AnthonyTuininga附加問題。如果您需要更多信息,只需詢問 – JellyWX
Ubuntu有一個修改後的Python,與cx_Freeze相沖突,我相信。如果您構建自己的Python,則問題應該消失。如果是這樣,請讓我知道。我會看看我是否可以通過Ubuntu安裝程序在我的端測試。 –