名为“cx_Freeze没有模块。——-cxFreeze python3.4实效”

时间:2022-06-20 02:09:09

I'm trying to use cxFreeze4.3.3(downloaded from sourceforge) in Ubuntu 32bits, where both python2 and python3.4 are installed. At first I ran

我尝试使用ubuntu32bit中的cxFreeze4.3.3(从sourceforge下载),在那里安装python2和python3.4。一开始我跑

python3.4 cxfreeze --help

And it printed help as wished. Then I ran

并按要求打印帮助。然后我跑

python3.4 cxfreeze /home/lz/dev/test/interface.py

an exception raised:

一个异常提出:

cx_Freeze.freezer.ConfigError: no base named Console

finally I specified the base name:

最后我指定了基名:

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'

After that I copied util.so from debian package.

之后我复制了util。所以从debian软件包。

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

Update: I tried to compile util.so from util.c,an error raised: Can't find "Python.h"

更新:我尝试编译util。所以从跑龙套。c,出现一个错误:找不到“Python.h”

I replaced #include with #include "python3.4/Python.h" or #include "python2.7/Python.h", but more error raised:

我将#include替换为#include“python3.4/Python”。h”或# include”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

Since PyQt5 is only available in python3, I have to use python3, and cxFreeze is said to be the only tool that supports python3. The cxFreeze debian package works well in python2.

由于PyQt5仅在python3中可用,所以我必须使用python3,并且cxFreeze据说是惟一支持python3的工具。cxFreeze debian软件包在python2中运行良好。

I really appreciate any help.

我真的很感激你的帮助。

1 个解决方案

#1


3  

Well, I've solved this problem.Here are the steps:

我已经解决了这个问题。下面是步骤:

  1. Download cx_freeze source from http://sourceforge.jp/projects/sfnet_cx-freeze/downloads/4.3.3/cx_Freeze-4.3.3.tar.gz/ and extract files
  2. 下载cx_freeze源代码,从http://sourceforge.jp/projects/sfnet_cx-freeze/downloads/4.3.3/cx_Freeze-4.3.3.tar.gz/并提取文件。
  3. Modify setup.py:line 79 to if True:
  4. 修改设置。py:第79行如果正确:
  5. Run sudo python3.4 setup.py install And then everything works well.
  6. 运行sudo python3.4设置。py安装后,一切都运行良好。

Thanks for @TomasK

感谢@TomasK

#1


3  

Well, I've solved this problem.Here are the steps:

我已经解决了这个问题。下面是步骤:

  1. Download cx_freeze source from http://sourceforge.jp/projects/sfnet_cx-freeze/downloads/4.3.3/cx_Freeze-4.3.3.tar.gz/ and extract files
  2. 下载cx_freeze源代码,从http://sourceforge.jp/projects/sfnet_cx-freeze/downloads/4.3.3/cx_Freeze-4.3.3.tar.gz/并提取文件。
  3. Modify setup.py:line 79 to if True:
  4. 修改设置。py:第79行如果正确:
  5. Run sudo python3.4 setup.py install And then everything works well.
  6. 运行sudo python3.4设置。py安装后,一切都运行良好。

Thanks for @TomasK

感谢@TomasK