Reputation: 139
I followed a [DigitalOcean guide]((https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-debian-10) to set up my Django site. It usually works fine but lately I keep running into this.
root@localhost:/usr/bin# sudo systemctl status gunicorn
Jun 13 21:27:43 localhost systemd[1]: Started gunicorn daemon.
Jun 13 21:27:43 localhost gunicorn[20611]: Traceback (most recent call last):
Jun 13 21:27:43 localhost gunicorn[20611]: File "/usr/bin/gunicorn", line 6, in <module>
Jun 13 21:27:43 localhost gunicorn[20611]: from gunicorn.app.wsgiapp import run
Jun 13 21:27:43 localhost gunicorn[20611]: ModuleNotFoundError: No module named 'gunicorn'
Jun 13 21:27:43 localhost systemd[1]: gunicorn.service: Main process exited, code=exited, status=1/FAILURE
Jun 13 21:27:43 localhost systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Jun 13 21:27:43 localhost systemd[1]: gunicorn.service: Start request repeated too quickly.
Jun 13 21:27:43 localhost systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Jun 13 21:27:43 localhost systemd[1]: Failed to start gunicorn daemon.
root@localhost:/home/development/django# which gunicorn
/usr/bin/gunicorn
/etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/home/development/django/
ExecStart=/usr/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
app.wsgi:application
[Install]
WantedBy=multi-user.target
Upvotes: 3
Views: 8758
Reputation: 181
I had the exact same problem and was going quite mad but here is what fixed it :
I guess systemd executes with sudo, but I did the pip install blabla
without being in sudo.
Found out by doing sudo gunicorn --version
and getting nothing.
So just doing sudo pip install gunicorn
solved it for me !
Disclaimer : I am probably doing something not at all in the "best practices" so don't hesitate to correct me or give a more detailed response than mine : First time answering :D
Upvotes: 4