首页 > 解决方案 > AttributeError:模块“dask”没有属性“set_options”

问题描述

我是使用 Dask 的新手,我在我的 MacBook MacOS High Sierra 10.13.6 上安装了新版本 2.12.0。当我尝试使用以下代码启动分布式模式时:

from dask.distributed import Client
c = Client()

我收到以下错误

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-67101dbde0b6> in <module>()
      1 from dask.distributed import Client
----> 2 c = Client()

~/anaconda3/lib/python3.6/site-packages/distributed/client.py in __init__(self, address, loop, timeout, set_as_default, scheduler_file, security, asynchronous, name, heartbeat_interval, **kwargs)
    554         if set_as_default:
    555             self._previous_get = _globals.get('get')
--> 556             dask.set_options(get=self.get)
    557             self._previous_shuffle = _globals.get('shuffle')
    558             dask.set_options(shuffle='tasks')

AttributeError: module 'dask' has no attribute 'set_options'

此外,如果我实例化c = Client(set_as_default=False)集群似乎成功提升,因为我获得了仪表板的连接信息(参见此图)。但是当我浏览仪表板时,会触发以下错误

根据文档,提升单个机器集群似乎微不足道,但我不知道可能出了什么问题。如果有人可以指导我如何解决此事件,我将不胜感激;)

标签: pythondaskdistributedattributeerror

解决方案


您的源文件名为,这会在您的模块和包dask.py之间引入命名冲突,您的模块在以后的导入语句中具有优先权。因此,当尝试调用时,这会失败,因为您的模块不提供此功能。dask.pydaskdistributed/client.pydask.set_optionsAttributeError

运行此dask.py模块后,python 缓存已编译的 python 代码。因此,即使您将模块重命名为其他名称,导入名称冲突仍然存在。要解决此问题,您应该删除__pycache__应该发现模块成功执行的目录。


推荐阅读