cx-freeze,runpy和multiprocessing - 多个失败路径

Ber*_*ker 32 python ubuntu multiprocessing cx-freeze python-3.4

这有点复杂,可能需要一些时间.

基本的问题是,在Linux上(在我的测试案例中是Ubuntu)我的程序(Omnitool)的cx-freeze'd版本无法创建子进程.但它适用于Windows 7.或者直接从源代码运行.不幸的是,它并不像遗忘那么简单freeze_support.

问题

启动子进程的默认行为是X服务器崩溃.具体如下:

XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 23 requests (23 known processed) with 0 events remaining.
[xcb]Unknown sequence number while processing queue 
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called 
[xcb] Aborting, sorry about that. 
Omnitool: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed. 
Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)

没有python回溯.我试图XInitThreads用ctypes 手动调用,它返回0表示成功设置,但无论如何崩溃.在崩溃之前Shorty,pygame UI漏掉了,所以我希望有一些错误.

现在,设置multiprocessing.set_start_method()更改问题:"forkserver"给了我这个可爱的回溯,它什么也没告诉我:

Pastebin例子

相反,将它设置为spawn只是让它不做任何事情.__main__正如我可以用打印件证明的那样,该过程开始并经历,但从不进入子过程的目标函数.

试着自己

确保你有使用python 3.4的Ubuntu或类似的Linux.然后获取所有依赖项:

从git下载omnitool作为zip或克隆:https: //github.com/Berserker66/omnitool requirements.txt在以下代码中来自Omnitool.

sudo apt-get update -qq
sudo apt-get install --fix-missing mercurial subversion python3-dev python3-numpy libav-tools libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libsdl1.2-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev python3-pip
pip3 install -r requirements.txt
pip3 install cx_Freeze
Run Code Online (Sandbox Code Playgroud)

要冻结,请omnisetup.py使用build参数运行.

我也试过用pyinstallers python 3 fork冻结,它失败的非常相似.但是spec文件不是git跟踪的.

sor*_*rin 0

我知道这可能不是您想听到的,但现实是您永远无法通过这种方法取得成功,原因如下:

  • Linux 没有可移植的 Python 包二进制文件,这意味着在一个发行版上编译的 numpy 可能无法在另一个发行版上运行。它甚至可能在相同的发行版和版本中发生,仅仅因为一个系统库收到了更新。
  • Manylinux1应该可以解决这个问题,但为其构建软件包确实很困难,而且只有少数人开始使用它。
  • cx-freeze 项目于 2014 年 12 月发布了最新版本,在 Python 时间尺度上将其视为一个废弃的项目。