跑pytorch代码报错AttributeError: module ‘distutils’ has no attribute ‘version’
Traceback (most recent call last):
File “D:/pycharm_envir/gaozhiyuan/Segmentation/pytorch_segmentation/deeplabv3-plus-pytorch-main/train.py”, line 16, in
from utils.callbacks import LossHistory, EvalCallback
File “D:\pycharm_envir\gaozhiyuan\Segmentation\pytorch_segmentation\deeplabv3-plus-pytorch-main\utils\callbacks.py”, line 17, in
from torch.utils.tensorboard import SummaryWriter
File “C:\software\anaconda3\envs\pytorch_gao\lib\site-packages\torch\utils\tensorboard_init_.py”, line 4, in
LooseVersion = distutils.version.LooseVersion
AttributeError: module ‘distutils’ has no attribute ‘version’
网上大多数方法是说使用pip uninstall setuptools卸载最新的setuptools,然后安装较老版本的
但是这个方法,亲测不太好用
这里建议直接使用pycharm修改源代码
第一步,进入这个代码里边
第二步,分别注释这几行代码文章来源:https://www.toymoban.com/news/detail-415196.html
LooseVersion = distutils.version.LooseVersion
if not hasattr(tensorboard, ‘version’) or LooseVersion(tensorboard.version) < LooseVersion(‘1.15’):
raise ImportError(‘TensorBoard logging requires TensorBoard version 1.15 or above’)
del LooseVersion
注释完就可以正常运行了文章来源地址https://www.toymoban.com/news/detail-415196.html
到了这里,关于AttributeError: module ‘distutils‘ has no attribute ‘version‘解决跑pytorch代码报错的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!