from torch.utils.tensorboard import SummaryWriter导入错误

tensorboard版本问题

在从Tensorboard中导入SummaryWriter模块时报错,为Tensorboard版本问题导致其不含有SummaryWriter模块,具体情况如下:

from torch.utils.tensorboard import SummaryWriter
ImportError: TensorBoard logging requires TensorBoard with Python summary writer installed. This should be available in 1.14 or above.

解决办法

已经安装过TensorBoard,但版本出了问题,按照错误提示进行更新,操作如下:

pip install future

若出现pip版本较低的警告,如:

pip install future
WARNING: You are using pip version 20.1.1; however, version 20.2 is available.

则按照提示更新pip,如下:

python -m pip install --upgrade pip

其后再次尝试

pip install future

更新完毕后开始安装对应版本的tensorboard,例如:

pip install tensorboard==1.14.0

所有步骤完成后再次运行

from torch.utils.tensorboard import SummaryWriter

将不再报错。

你可能感兴趣的:(学习,python,bug,tensorflow)