Question

ModuleNotFoundError error when running sudo systemctl status gunicorn

Posted August 31, 2021 201 views
UbuntuDjangoPython Frameworks

I’m trying to deploy a Django project on Ubuntu server. I’m folwing your guide.

But I’m facing a problem when I run this command sudo systemctl status gunicorn, I get the error below.

All the commands related to gunicorn mentioned in the guide (before this sudo systemctl status gunicorn) work fine.

● gunicorn.service - gunicorn daemon
     Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2021-08-31 20:53:12 UTC; 6min ago
TriggeredBy: ● gunicorn.socket
    Process: 1918 ExecStart=/home/houssem/project/env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/gunicorn.sock config.wsgi:application (code=exited, >
   Main PID: 1918 (code=exited, status=3)

Aug 31 20:53:12 ubuntu-20-lts gunicorn[1932]:   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Aug 31 20:53:12 ubuntu-20-lts gunicorn[1932]:   File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Aug 31 20:53:12 ubuntu-20-lts gunicorn[1932]: ModuleNotFoundError: No module named 'django_extensions'
Aug 31 20:53:12 ubuntu-20-lts gunicorn[1932]: [2021-08-31 20:53:12 +0000] [1932] [INFO] Worker exiting (pid: 1932)
Aug 31 20:53:12 ubuntu-20-lts gunicorn[1918]: [2021-08-31 20:53:12 +0000] [1918] [WARNING] Worker with pid 1931 was terminated due to signal 15
Aug 31 20:53:12 ubuntu-20-lts gunicorn[1918]: [2021-08-31 20:53:12 +0000] [1918] [WARNING] Worker with pid 1932 was terminated due to signal 15
Aug 31 20:53:12 ubuntu-20-lts gunicorn[1918]: [2021-08-31 20:53:12 +0000] [1918] [INFO] Shutting down: Master
Aug 31 20:53:12 ubuntu-20-lts gunicorn[1918]: [2021-08-31 20:53:12 +0000] [1918] [INFO] Reason: Worker failed to boot.
Aug 31 20:53:12 ubuntu-20-lts systemd[1]: gunicorn.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
Aug 31 20:53:12 ubuntu-20-lts systemd[1]: gunicorn.service: Failed with result 'exit-code'.

Please, how can fix this?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @oussamahel,

It looks as if your sample project relies on django-extensions. You can install it by using pip to do so:

pip install django-extensions

Once you have installed django-extensions, you may get a different import error if there are other packages missing. Hopefully, your sample project will have a requirements.txt file which lists the requirements. If so, you can install the required packages with:

pip install -r requirements.txt

Additionally, you can skip the last step and install those that appear as missing modules.

  • Thank you for your answer.
    I’ve already created a virtualenv and installed all the packages.
    Also, I’ve tried to install django-extensions globally but still have the same error.

    Any thoughts?