gpt4 book ai didi

linux - 在 Linux 中使用多进程模块时,pyinstaller 不创建工作可执行文件

转载 作者:太空宇宙 更新时间:2023-11-04 12:07:03 24 4
gpt4 key购买 nike

我创建了一个小样本来演示我在尝试使用 pyinstaller 构建可执行程序时遇到的错误。我的 python 是 3.6.5,安装在/home/repos/ges/Python/bin。我不确定非标准 python 安装是否在错误中发挥了作用。

import time
import random
from multiprocessing.dummy import Pool as ThreadPool


# A function to run against a list
def this_job(job):

time_delay = random.randrange(0, 5)
time.sleep(time_delay)

print("after a small " + str(time_delay) + " second delay here is job " + str(job))


forked_jobs = []
for i in range(500):
forked_jobs.append(i)


# Make the Pool of workers and do the work
pool = ThreadPool(10)
pool.map(this_job, forked_jobs)
# close the pool and wait for the work to finish
pool.close()
pool.join()

我可以从编写它的地方运行该文件,并看到类似于以下的输出:

经过 0 秒的小延迟后,这里是作业 52

经过 0 秒的小延迟后,这里是作业 117

经过 1 秒的小延迟后,这里是作业 39

经过 1 秒的小延迟后,这里是作业 65...

当我尝试使用 ./python3 pyinstaller bp2.py 构建它并运行 dist 文件夹中的可执行文件时,我看到以下错误。

追溯(最近的调用最后): 文件“site-packages/PyInstaller/loader/rthooks/pyi_rth_multiprocessing.py”,第 8 行,在 exec_module 中的文件“/home/repos/ges/Python/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py”,第 631 行 执行(字节码,模块。dict) 文件“multiprocessing/spawn.py”,第 19 行,位于 从 。导入工具 exec_module 中的文件“/home/repos/ges/Python/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py”,第 631 行 执行(字节码,模块。dict) 文件“multiprocessing/util.py”,第 17 行,位于 从子进程导入 _args_from_interpreter_flags exec_module 中的文件“/home/repos/ges/Python/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py”,第 631 行 执行(字节码,模块。dict) 文件“subprocess.py”,第 136 行,位于 文件“/home/repos/ges/Python/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py”,第 714 行,在 load_module module = loader.load_module(全名)ImportError:/home/repos/ges/Python/GES_Module/dist/bp2/_posixsubprocess.so: undefined symbol: _Py_set_inheritable_async_safe[15670] 无法执行脚本 pyi_rth_multiprocessing

不确定如何解决。

最佳答案

看来我收到这个错误是因为我的 python 构建位置。我在典型位置安装了 python 的机器上测试了上面的内容,它按预期工作。

关于linux - 在 Linux 中使用多进程模块时,pyinstaller 不创建工作可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50337522/

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