小编Mar*_*ari的帖子

运行时错误:Mac 上的freeze_support()

我是python的新手。我想学习如何在 python 中并行处理。我看到了以下示例:


import multiprocessing as mp

np.random.RandomState(100)
arr = np.random.randint(0, 10, size=[20, 5])
data = arr.tolist()

def howmany_within_range_rowonly(row, minimum=4, maximum=8):
    count = 0
    for n in row:
    if minimum <= n <= maximum:
        count = count + 1
    return count

pool = mp.Pool(mp.cpu_count())

results = pool.map(howmany_within_range_rowonly, [row for row in data])

pool.close()

print(results[:10])
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,发生了这个错误:

RuntimeError: 
    An attempt has been made to start a new process before the
    current process has finished its bootstrapping phase.

    This probably means that you …
Run Code Online (Sandbox Code Playgroud)

python macos

4
推荐指数
1
解决办法
1935
查看次数

标签 统计

macos ×1

python ×1