Question

ModuleNotFoundError error when running sudo systemctl status gunicorn

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?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.