Torch.save / TypeError: file must have a 'write' attribute

i load the old model and train, but when i save the model with the same name, i get this error:

Traceback (most recent call last):
File “main.py”, line 66, in
train_model(config, dataset)
File “main.py”, line 41, in train_model
model_controller.train()
File “/data1//workspace/matchLSTM-pytorch/utils/model_controller.py”, line 97, in train self.save_model(epoch)
File “/data1/workspace/matchLSTM-pytorch/utils/model_controller.py”, line 210, in save_model
torch.save(model_weight, self.model_weight_path)
File “/data1//local/anaconda3/lib/python3.5/site-packages/torch/serialization.py”, line 161, in save
return _with_file_like(f, “wb”, lambda f: _save(obj, f, pickle_module, pickle_protocol))
File “/data1/local/anaconda3/lib/python3.5/site-packages/torch/serialization.py”, line 118, in _with_file_like
return body(f)
File “/data1/local/anaconda3/lib/python3.5/site-packages/torch/serialization.py”, line 161, in
return _with_file_like(f, “wb”, lambda f: _save(obj, f, pickle_module, pickle_protocol))
File “/data1/local/anaconda3/lib/python3.5/site-packages/torch/serialization.py”, line 227, in _save
pickle_module.dump(MAGIC_NUMBER, f, protocol=pickle_protocol)
TypeError: file must have a ‘write’ attribute

i solve this problem by remove old model path

How to remove old path