环境:Mac os、Anaconda3

通过conda create -n tf36 python=3.6新建tensorflow的python环境,通过pip install tensorflow命令安装,启动tensorboard报错。

命令:tensorboard --logdir='path/to/log'

错误提示:ImportError: cannot import name 'ReparseException',表示从html5lib引入ReparseException错误。

tensorboard ImportError: cannot import name 'ReparseException'

解决方案:根据提示找到sanitizer.py文件,定位到报错内容:

import html5lib
from html5lib.constants import (
    entities,
    ReparseException,
    namespaces,
    prefixes,
    tokenTypes,
)
表示从html5lib.constant不能导入ReparseException,定位到html5lib.constant,看看是否存在ReparseException,发现只存在_ReparseException:

tensorboard ImportError: cannot import name 'ReparseException'

修改sanitizer.py文件内容,将ReparseException替换为_ReparseException

tensorboard ImportError: cannot import name 'ReparseException'

重新运行命令:tensorboard --logdir='path/to/log'

tensorboard ImportError: cannot import name 'ReparseException'

在chrome中输入:http://localhost:6006/,出现以下内容,表示成功

tensorboard ImportError: cannot import name 'ReparseException'

相关文章: