【问题标题】:AttributeError: module 'collections' has no attribute 'MutableSet'AttributeError: 模块 \'collections\' 没有属性 \'MutableSet\'
【发布时间】:2022-10-26 03:39:10
【问题描述】:

我编写了一个 MLflow 组件来上传和记录从 URL 到 WandB 的工件。我正在尝试在 conda 环境中运行脚本,但不幸的是我遇到了这个错误

File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\__init__.py", line 38, in <module>
    from wandb import sdk as wandb_sdk
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\sdk\__init__.py", line 12, in <module>
    from .wandb_init import init  # noqa: F401
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\sdk\wandb_init.py", line 29, in <module>
    from .backend.backend import Backend
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\sdk\backend\backend.py", line 18, in <module>
    from ..internal.internal import wandb_internal
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\sdk\internal\internal.py", line 34, in <module>
    from . import sender
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\sdk\internal\sender.py", line 18, in <module>
    from wandb.filesync.dir_watcher import DirWatcher
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\filesync\dir_watcher.py", line 10, in <module>
    wd_polling = util.vendor_import("watchdog.observers.polling")
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\util.py", line 170, in vendor_import
    module = import_module(name)
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\vendor\watchdog\observers\__init__.py", line 92, in <module>
    from .polling import PollingObserver as Observer
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\vendor\watchdog\observers\polling.py", line 43, in <module>
    from watchdog.observers.api import (
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\vendor\watchdog\observers\api.py", line 23, in <module>
    from watchdog.utils.bricks import SkipRepeatsQueue
  File "C:\anaconda\envs\mlflow-4b67c93d2a95df2e00cbf3c9f644d2e3dada00e0\lib\site-packages\wandb\vendor\watchdog\utils\bricks.py", line 175, in <module>
    class OrderedSet(collections.MutableSet):
AttributeError: module 'collections' has no attribute 'MutableSet'
2022/10/09 20:55:53 ERROR mlflow.cli: === Run (ID 'e5ad70e5104e4a50ad3f66a891bdbf81') failed ===

我已经在我的环境中安装了 WandB==0.13.2 & protobuf==3.20.3 & Mlflow 最新版本。 我认为这是因为依赖不匹配而发生的,但不确定。

此外,我还在我的 conda.yml 文件中为 mlflow 组件脚本添加了 WandB 和 Protobuf。

提前致谢。

【问题讨论】:

  • 你的python是什么版本的?
  • Python 版本 =3.8.13 @TalhaTayyab

标签: python anaconda mlflow wandb


【解决方案1】:

我在用python编码时遇到了这个问题,在新版本的python集合中没有更多的MutableSet、MutableMapping等。但是模块collections.abc有它,所以如果你想你可以这样:

import collections 
if sys.version_info.major == 3 and sys.version_info.minor >= 10
    from collections.abc import MutableSet
    collections.MutableSet = collections.abc.MutableSet
else 
    from collections import MutableSet

来源:https://www.datasciencelearner.com/attributeerror-module-collections-has-no-attribute-mutablemapping/

【讨论】:

    猜你喜欢
    • 2017-08-02
    • 2022-06-14
    • 2022-06-26
    • 1970-01-01
    • 1970-01-01
    • 2021-11-29
    • 2021-12-04
    • 2022-07-20
    相关资源
    最近更新 更多