ImportError: cannot import name ‘Mapping‘ from ‘collections‘

PS D:\Pycharm_data\小土堆pytorch学习> tensorboard --logdir=logs
Traceback (most recent call last):
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Scripts\tensorboard-script.py", line 5, in 
    from tensorboard.main import run_main
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\main.py", line 27, in 
    from tensorboard import default
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\default.py", line 33, in 
    from tensorboard.plugins.audio import audio_plugin
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\plugins\audio\audio_plugin.py", line 23, in 
    from tensorboard import plugin_util
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\plugin_util.py", line 20, in 
    from tensorboard._vendor.bleach.sanitizer import Cleaner
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\_vendor\bleach\__init__.py", line 5, in 
    from tensorboard._vendor.bleach.linkifier import (
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\_vendor\bleach\linkifier.py", line 4, in 
    from tensorboard._vendor import html5lib
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\_vendor\html5lib\__init__.py", line 25, in 
    from .html5parser import HTMLParser, parse, parseFragment
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\_vendor\html5lib\html5parser.py", line 8, in 
    from . import _tokenizer
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\_vendor\html5lib\_tokenizer.py", line 16, in 
    from ._trie import Trie
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\_vendor\html5lib\_trie\__init__.py", line 3, in 
    from .py import Trie as PyTrie
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\_vendor\html5lib\_trie\py.py", line 6, in 
    from ._base import Trie as ABCTrie
  File "D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\site-packages\tensorboard\_vendor\html5lib\_trie\_base.py", line 3, in 
    from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (D:\Anaconda3_2022.10\envs\pytorch_cuda11.8\Lib\collections\__init__.py)

当我执行 tensorboard --logdir=logs语句时,总是报错,修改logs为绝对地址也不行
后面发现只需在所用的Anconda创建的环境里执行这段代码安装好就可以

pip install tensorboard -U

-U 标志会强制安装最新版本,即使您已经安装了一个旧版本的 tensorboard。这可以用来更新 tensorboard 到最新可用的版本。

你可能感兴趣的:(pytorch)