我試圖在Ubuntu 32位中使用cxFreeze4.3.3(從sourceforge下載),其中python2和python3.4都安裝了。 起初我跑在python3.4中沒有名爲'cx_Freeze.util'的模塊--- cxFreeze
python3.4 cxfreeze --help
而作爲希望它打印的幫助。 然後我跑
python3.4 cxfreeze /home/lz/dev/test/interface.py
引發異常:
cx_Freeze.freezer.ConfigError: no base named Console
最後我指定的基本名稱:
python3.4 cxfreeze --base-name=/home/lz/dev/test/interface.py /home/lz/dev/test/interface.py
File "cxfreeze", line 5, in <module>
main()
File "/home/lz/cx_Freeze-4.3.3/cx_Freeze/main.py", line 188, in main
freezer.Freeze()
File "/home/lz/cx_Freeze-4.3.3/cx_Freeze/freezer.py", line 599, in Freeze
import cx_Freeze.util
ImportError: No module named 'cx_Freeze.util'
之後,我複製util.so從Debian軟件包。
ImportError: /home/lz/cx_Freeze-4.3.3/cx_Freeze/util.so: undefined symbol: Py_InitModule4
更新:我試圖從util.c編譯util.so,提出了一個錯誤:
我替換的#include的#include 找不到 「Python.h」「python3 0.4/Python.h」或#包括 「python2.7/Python.h」,而是提出了更多的錯誤:
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 20 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_info): relocation 21 has invalid symbol index 22
/usr/bin/ld: /usr/lib/debug/usr/lib/i386-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/crt1.o:In function‘_start’:
(.text+0x18):‘main’ undefined reference
/tmp/ccMQ0pWq.o:In function‘ExtSetOptimizeFlag’:
util.c:(.text+0xa):‘Py_OptimizeFlag’ undefined reference
util.c:(.text+0x1d):‘PyArg_ParseTuple’ undefined reference
util.c:(.text+0x2d):‘_Py_NoneStruct’ undefined reference
util.c:(.text+0x35):‘_Py_NoneStruct’ undefined reference
util.c:(.text+0x3a):‘_Py_NoneStruct’ undefined reference
/tmp/ccMQ0pWq.o:In function ‘Module_Initialize’:
util.c:(.text+0x56):‘PyModule_Create2’ undefined reference
Compiling failed
collect2: error: ld returned 1 exit status
由於PyQt5僅在python3可用,我不得不使用python3,並且cxFreeze說成爲唯一支持python3的工具。 cxFreeze debian包在python2中運行良好。
我真的很感激任何幫助。
更改包括回到剛纔'python.h',並確保已安裝'python3-dev'(從APT)。您可能還需要進行[本期]中描述的更改(https://bitbucket.org/anthony_tuininga/cx_freeze/issue/32/cant-compile-cx_freeze-in-ubuntu-1304)以使其能夠編譯。 – 2014-10-02 16:40:22
@ThomasK謝謝。安裝了python3-dev,而#include「Python.h」或「python.h」仍然無法找到。 – user241008 2014-10-03 03:35:18