Module 'PIL.Image' has no attribute 'register_extensions'

I have a problem as mentioned in the title, and it is in colab. I found out that many people have the same problem, and generally it worked for them, but it does not work for me.

I tried to add this:

!pip install pillow==4.1.1
%reload_ext autoreload


!pip uninstall -y Pillow
!pip install Pillow==5.3.0
import PIL

but it did not solve my problem.

the error in th context:

AttributeError Traceback (most recent call last)
in ()
----> 1 images, labels =

/usr/local/lib/python3.6/dist-packages/torch/utils/data/ in next(self)
320 if self.rcvd_idx in self.reorder_dict:
321 batch = self.reorder_dict.pop(self.rcvd_idx)
–> 322 return self._process_next_batch(batch)
324 if self.batches_outstanding == 0:

/usr/local/lib/python3.6/dist-packages/torch/utils/data/ in _process_next_batch(self, batch)
355 self._put_indices()
356 if isinstance(batch, ExceptionWrapper):
–> 357 raise batch.exc_type(batch.exc_msg)
358 return batch

If you are trying to install pytorch on co-lab
Just type this it will install all modules including pytorch and all dependencies

 !pip3 install torchvision

I already did, pytorch and torchvision are working fine, but I get this error.
In here it is mentioned that apparently it is a common problem, but my problem was not solved.