Getting No module named 'storages.backends.s3boto' when boto is installed

Viewed 2979

I recently upgraded to Django 3 and installed a new virtual environment.

I installed all the dependent modules until I got to boto.

I installed django storages with the following command:

pip3  install django-storages

I still received the error:

File "custom_storage.py", line 2, in <module>
    from storages.backends.s3boto import S3BotoStorage
ModuleNotFoundError: No module named 'storages.backends.s3boto'

Here is what my custom_storages.py looks like:

from storages.backends.s3boto import S3BotoStorage

class StaticStorage(S3BotoStorage):
    location = settings.STATICFILES_LOCATION

class MediaStorage(S3BotoStorage):
    location = settings.MEDIAFILES_LOCATION

I then tried to install boot directly with the following command:

pip3  install boto3

I still get the above error.

Is there anything else needed to be installed to get past this error?

4 Answers

It looks like django-storages is no longer being maintained.

I installed redux instead:

pip3 install django-storages-redux

There are then compatibility issues with Django 3 and Redux. I then changed the following files:

sudo vi /venv/lib/python3.7/site-packages/storages/compat.py

Line 1 and 2 should remove references to "Six" and should now read:

from urllib import parse as urlparse
from io import BytesIO

I then changed line 14 and 15 in the file:

venv/lib/python3.7/site-packages/storages/backends/s3boto3.py

They should now read:

from io import BytesIO
from urllib import parse as urlparse

from storages.backends.s3boto import S3BotoStorage

should now be

from storages.backends.s3boto3 import S3Boto3Storage

It looks like django-storages is alive again, but the backend in settings.py should now be 'storages.backends.s3boto3.S3Boto3Storage'.

Try out these Steps.

  1. Check if you have added 'storages' in INSTALLED_APPS
  2. Make sure your project is running in the virtual environment.
  3. Make sure you have virtual environment active before those pip installs
  4. Restart the Service. If its Daemon
  5. Manually go to virtualenv/lib/pythonx.x/site-packages/ search for boto3
Related