How to Solve Error Message ModuleNotFoundError : No module named ‘whitenoise’ when executing python collectstatic

Posted on

This is another article which has a focus on how to solve an error message exist while executing the command ‘python collectstatic’. Actually, there is a definition of a specific context of ‘whitenoise’ in the file. It exist in the file of ‘’. The definition for the context exist as follows :

STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

The above source code definition is useful in order to load static file like ‘css’, ‘js’ or ‘images’ in the Django-based application. Actually, the impact of the above definition exist after executing the command of ‘python collectstatic’.

(env) user@hostname:~/python/django/todoproject$ python collectstatic
Traceback (most recent call last):
  File "", line 21, in 
  File "", line 17, in main
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/core/management/", line 381, in execute_from_command_line
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/core/management/", line 375, in execute
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/core/management/", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/core/management/", line 364, in execute
    output = self.handle(*args, **options)
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/", line 162, in handle
    if self.is_local_storage() and
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/", line 216, in is_local_storage
    return isinstance(, FileSystemStorage)
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/utils/", line 256, in inner
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/contrib/staticfiles/", line 498, in _setup
    self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/core/files/", line 358, in get_storage_class
    return import_string(import_path or settings.DEFAULT_FILE_STORAGE)
  File "/home/user/python/django/env/lib/python3.7/site-packages/django/utils/", line 17, in import_string
    module = import_module(module_path)
  File "/home/user/python/django/env/lib/python3.7/importlib/", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 953, in _find_and_load_unlocked
  File "", line 219, in _call_with_frames_removed
  File "", line 1006, in _gcd_import
  File "", line 983, in _find_and_load
  File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'whitenoise'
(env) user@hostname:~/python/django/todoproject$ 

The solution for the above error message is definitely simple. It is because the information is already exist in the error message. It is because there is no module with the name of ‘whitenoise’. So, solving the problem is just installing that module. Below is the step for installing the module to solve the problem :

1Just install the suitable module by executing the following command :

(env) user@hostname:~/python/django/todoproject$ pip install whitenoise
Collecting whitenoise
  Downloading whitenoise-5.0.1-py2.py3-none-any.whl (20 kB)
Installing collected packages: whitenoise
Successfully installed whitenoise-5.0.1
(env) user@hostname:~/python/django/todoproject$

Actually, if there is no other requirement and everything is running well. The execution of the ‘python collectstatic’ will be a success. Below is the execution of the command if it is a success :

(env) user@hostname:~/python/django/todoproject$ python collectstatic

119 static files copied to '/home/user/python/django/todoproject/todoproject/static'.
(env) user@hostname:~/python/django/todoproject$ python runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
March 15, 2020 - 09:07:23
Django version 2.2.6, using settings 'todoproject.settings'
Starting development server at
Quit the server with CONTROL-C.

2 thoughts on “How to Solve Error Message ModuleNotFoundError : No module named ‘whitenoise’ when executing python collectstatic

Leave a Reply