python - 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)
集群似乎成功提升,因为我获得了仪表板的连接信息(参见此图)。但是当我浏览仪表板时,会触发以下错误。
根据文档,提升单个机器集群似乎微不足道,但我不知道可能出了什么问题。如果有人可以指导我如何解决此事件,我将不胜感激;)
解决方案
您的源文件名为,这会在您的模块和包dask.py
之间引入命名冲突,您的模块在以后的导入语句中具有优先权。因此,当尝试调用时,这会失败,因为您的模块不提供此功能。dask.py
dask
distributed/client.py
dask.set_options
AttributeError
运行此dask.py
模块后,python 缓存已编译的 python 代码。因此,即使您将模块重命名为其他名称,导入名称冲突仍然存在。要解决此问题,您应该删除__pycache__
应该发现模块成功执行的目录。
推荐阅读
- javascript - 隐藏使用 JavaScript 动态创建的输入按钮
- mysql - 将数据从 laravel 表单存储到数据库有多少种方法?
- azure-functions - 使用 az rest 获取 azure 功能键
- vscode-extensions - 在 VS Code Webview 中使用浅色/深色主题图标
- powershell - Powershell 将变量转换为 utf-16
- python - 在python中实现负对数似然函数
- python - 随机化 DataFrame 列中的值
- typo3 - 在 TYPO3 7.6 中使用 solrfal 3.1.0 在 flexform 字段中链接的索引文件
- sql - 在日期字段中减去两次
- javascript - 快递,摩卡测试总是返回404