ModuleNotFoundError: No module named 'storages'

364 Views Asked by At

I no idea why this error kept occur in my terminal

my current django version, 4.2.3 python version, 3.10.6

and my virtual environment is on, and I did downloaded these pip

pip install boto3 pip install django-storages

and my settings.py


    INSTALLED_APPS=[
    ...
    'storages',
    ]
    
    and 
    
    DEFAULT_FILE_STORAGE='storages.backends.s3boto3.S3Boto3Storage'

ok then, I try to run my server, python manage.py runserver

it came out these error

**

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Python latest\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Python latest\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\User\Desktop\udemy react django e commerce\env\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\User\Desktop\udemy react django e commerce\env\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run   
    autoreload.raise_last_exception()
  File "C:\Users\User\Desktop\udemy react django e commerce\env\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "C:\Users\User\Desktop\udemy react django e commerce\env\lib\site-packages\django\core\management\__init__.py", line 394, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Users\User\Desktop\udemy react django e commerce\env\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\User\Desktop\udemy react django e commerce\env\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\User\Desktop\udemy react django e commerce\env\lib\site-packages\django\apps\registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "C:\Users\User\Desktop\udemy react django e commerce\env\lib\site-packages\django\apps\config.py", line 193, in create
    import_module(entry)
  File "C:\Python latest\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'storages'

**

Which mean my terminal can't get the storages module even I downloaded boto3 and django-storages, can someone help me?

Thank You

1

There are 1 best solutions below

3
0urz4g On

Please double-check that you have correctly installed this :

pip install boto3 django-storages

Found in the django-storages documentation :

https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#configuration-settings

DEFAULT_FILE_STORAGE = "storages.backends.s3.S3Storage"

This setting was for Django < v4.2

In your case (Django > 4.2), use :

STORAGES = {
    "default": {
        "BACKEND": "storages.backends.s3.S3Storage",
        "OPTIONS": {
          ...your_options_here
        },
    },
}

Not found in the django-storages documentation (v1.14 = latest at this moment) :

INSTALLED_APPS=[
    ...
    'storages',
    ]

Is it really necessary ?