gpt4 book ai didi

python - cx-freeze、runpy 和 multiprocessing - 多条失败路径

转载 作者:IT老高 更新时间:2023-10-28 21:58:43 26 4
gpt4 key购买 nike

这有点复杂,可能需要您花费一些时间。

基本问题是,在 linux(我的测试用例中是 Ubuntu)上,我的程序 (Omnitool) 的 cx-freeze 版本无法创建子进程。但是,它适用于 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)

没有python回溯。我尝试使用 ctypes 手动调用 XInitThreads,它返回 0 表示成功设置,但无论如何都会崩溃。崩溃前不久,pygame UI 出现错误,所以我预计那里有问题。

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

Pastebin Example

相反,将其设置为产卵只会使其不执行任何操作。进程开始,并通过 __main__,我可以用 prints 证明,但从未进入子进程的目标函数。

尝试自己

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

以 zip 格式下载 omnitool 或从 git 克隆: 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

要卡住,请使用 build 参数运行 omnisetup.py

我也尝试过使用 pyinstallers python 3 fork 进行卡住,但失败非常相似。规范文件没有被 git 跟踪。

最佳答案

我在工作项目中使用了 cx_freeze。我不确定这是否是您的问题...但我使用的是 Anaconda 发行版,并且 cx_freeze 没有正确收集我的项目所需的 .dll。

解决办法是:

  1. 安装平面版 Python
  2. 使用该项目所需的包创建环境
  3. 运行 cx_freeze。

神奇地,所有的问题都消失了,所有的东西都按预期编译了。

关于python - cx-freeze、runpy 和 multiprocessing - 多条失败路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31943174/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com