DataLearner 标志DataLearnerAI
最新AI资讯
大模型排行榜
大模型评测基准
大模型列表
大模型对比
资源中心
工具
语言中文
DataLearner 标志DataLearner AI

专注大模型评测、数据资源与实践教学的知识平台,持续更新可落地的 AI 能力图谱。

产品

  • 评测榜单
  • 模型对比
  • 数据资源

资源

  • 部署教程
  • 原创内容
  • 工具导航

关于

  • 关于我们
  • 隐私政策
  • 数据收集方法
  • 联系我们

© 2026 DataLearner AI. DataLearner 持续整合行业数据与案例,为科研、企业与开发者提供可靠的大模型情报与实践指南。

隐私政策服务条款
  1. 首页/
  2. 博客列表/
  3. 博客详情

运行dask程序报错:Task exception was never retrieved

2021/06/07 22:42:03
6,285 阅读
daskpython编程

运行本地dask集群的时候出错,报错信息如下:

Task exception was never retrieved
future: <Task finished coro=<_wrap_awaitable() done, defined at D:\Program Files\Python3.7\lib\asyncio\tasks.py:592> exception=RuntimeError('\n        An attempt has been made to start a new process before the\n        current process has finished its bootstrapping phase.\n\n        This probably means that you are not using fork to start your\n        child processes and you have forgotten to use the proper idiom\n        in the main module:\n\n            if __name__ == \'__main__\':\n                freeze_support()\n...\n\n        The "freeze_support()" line can be omitted if the program\n        is not going to be frozen to produce an executable.')>
Traceback (most recent call last):
  File "D:\Program Files\Python3.7\lib\asyncio\tasks.py", line 599, in _wrap_awaitable
    return (yield from awaitable.__await__())
  File "D:\Program Files\Python3.7\lib\site-packages\distributed\nanny.py", line 291, in start
    response = await self.instantiate()
  File "D:\Program Files\Python3.7\lib\site-packages\distributed\nanny.py", line 374, in instantiate
    result = await self.process.start()
  File "D:\Program Files\Python3.7\lib\site-packages\distributed\nanny.py", line 567, in start
    await self.process.start()
  File "D:\Program Files\Python3.7\lib\site-packages\distributed\process.py", line 34, in _call_and_set_future
    res = func(*args, **kwargs)
  File "D:\Program Files\Python3.7\lib\site-packages\distributed\process.py", line 202, in _start
    process.start()
  File "D:\Program Files\Python3.7\lib\multiprocessing\process.py", line 112, in start
    self._popen = self._Popen(self)
  File "D:\Program Files\Python3.7\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "D:\Program Files\Python3.7\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "D:\Program Files\Python3.7\lib\multiprocessing\popen_spawn_win32.py", line 33, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "D:\Program Files\Python3.7\lib\multiprocessing\spawn.py", line 143, in get_preparation_data
    _check_not_importing_main()
  File "D:\Program Files\Python3.7\lib\multiprocessing\spawn.py", line 136, in _check_not_importing_main
    is not going to be frozen to produce an executable.''')
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 are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

提示Task exception was never retrieved。

代码如下:

import dask.dataframe as dd
from dask.distributed import Client, LocalCluster

import pandas as pd
cluster = LocalCluster(dashboard_address=None)
client = Client(cluster)
df = pd.DataFrame([[1, 1, 1], [2, 2, 2]])
df = dd.from_pandas(df, npartitions=1)
print(df.head())

这个问题在dask社区中有讨论( https://github.com/modin-project/modin/issues/843 ),具体原因还不是特别清楚,讨论过程看可能与modin或者ray有关系,解决方法很简单,加入main方法即可:

import dask.dataframe as dd
from dask.distributed import Client, LocalCluster

import pandas as pd

if __name__ == '__main__':
    cluster = LocalCluster(dashboard_address=None)
    client = Client(cluster)
    df = pd.DataFrame([[1, 1, 1], [2, 2, 2]])
    df = dd.from_pandas(df, npartitions=1)
    print(df.head())

DataLearner 官方微信

欢迎关注 DataLearner 官方微信,获得最新 AI 技术推送

DataLearner 官方微信二维码
返回博客列表

相关博客

  • Dask concat throws ValueError: Shape of passed values is (xxx, xxx), indices imply (xxx, xxx)
  • Dask调度器简介
  • Dask的Merge操作性能对比
  • Dask分布式任务中包含写文件的方法时候,程序挂起不结束的解决方案
  • pandas.DataFrame.to_csv和dask.dataframe.to_csv在windows下保存csv文件出现多个换行结果
  • dask的dataframe的值变成1和foo的解决方法
  • 通过命令行的方式建立Dask集群
  • 并行计算中如何提高处理效率——来自Dask的提示

热门博客

  • 1Dirichlet Distribution(狄利克雷分布)与Dirichlet Process(狄利克雷过程)
  • 2回归模型中的交互项简介(Interactions in Regression)
  • 3贝塔分布(Beta Distribution)简介及其应用
  • 4矩母函数简介(Moment-generating function)
  • 5普通最小二乘法(Ordinary Least Squares,OLS)的详细推导过程
  • 6使用R语言进行K-means聚类并分析结果
  • 7深度学习技巧之Early Stopping(早停法)
  • 8手把手教你本地部署清华大学的ChatGLM-6B模型——Windows+6GB显卡本地部署