没有名为' cx_Freeze.util' --- python3.4中的cxFreeze

时间:2014-10-02 03:49:32

标签: python python-3.x cx-freeze

我试图在Ubuntu 32位中使用cxFreeze4.3.3(从sourceforge下载),其中安装了python2和python3.4。 起初我跑了

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'

之后我从debian包复制了util.so。

ImportError: /home/lz/cx_Freeze-4.3.3/cx_Freeze/util.so: undefined symbol: Py_InitModule4

更新:我尝试从util.c编译util.so,引发了一个错误: 无法找到&#34; Python.h&#34;

我将#include替换为#include&#34; python3.4 / Python.h&#34;或#include&#34; python2.7 / Python.h&#34;,但引发了更多错误:

/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中运行良好。

我非常感谢任何帮助。

1 个答案:

答案 0 :(得分:3)

好吧,我已经解决了这个问题。这是步骤:

  1. http://sourceforge.jp/projects/sfnet_cx-freeze/downloads/4.3.3/cx_Freeze-4.3.3.tar.gz/下载cx_freeze来源并解压缩文件
  2. 将setup.py:line 79修改为if True:
  3. 运行sudo python3.4 setup.py install 然后一切运作良好。
  4. 感谢@TomasK