我是 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)
集群似乎成功启动,因为我获得了仪表板 (see this image) 的连接信息。但是当我浏览仪表板时 following error is triggered .
根据documentation提升单个机器集群似乎微不足道,但我不知道哪里出了问题。如果有人可以指导我如何解决此事件,我将不胜感激;)
最佳答案
您的源文件名为 dask.py
,这在您的模块 dask.py
和 dask
包之间引入了命名冲突,您的模块在以后的导入语句中优先。因此,当 distributed/client.py
尝试调用 dask.set_options
时,由于您的模块未提供此功能,因此失败并返回 AttributeError
。
运行此dask.py
模块后,python 会缓存已编译的python 代码。因此,即使您将模块重命名为其他名称,导入名称冲突仍然存在。要解决此问题,您应该删除 __pycache__
目录,之后您应该会发现您的模块已成功执行。
关于python - AttributeError: 模块 'dask' 没有属性 'set_options',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60733557/