Atma
Atma

Reputation: 29795

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

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?

Upvotes: 3

Views: 7582

Answers (4)

Tom
Tom

Reputation: 22841

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

Upvotes: 2

lostbard
lostbard

Reputation: 5230

from storages.backends.s3boto import S3BotoStorage

should now be

from storages.backends.s3boto3 import S3Boto3Storage

Upvotes: 4

Atma
Atma

Reputation: 29795

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

Upvotes: 3

Adharsh M
Adharsh M

Reputation: 3832

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

Upvotes: 2

Related Questions