You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

配置Gunicorn与Django时出现No module named revamp.wsgi错误求助

Fixing "ImportError: No module named revamp.wsgi" with Gunicorn Systemd Service

Alright, let's get that Gunicorn service up and running. The error you're seeing happens because Gunicorn isn't looking in the right directory to find your Django project's WSGI module—even though the file exists, the working context is off.

Here's what to do:

  1. Update your Gunicorn systemd config
    Open your /etc/systemd/system/gunicorn.service file and adjust the WorkingDirectory path. Right now it's set to /home/muiruri_samuel/webapp, but your Django project's root (where the revamp package containing wsgi.py lives) is one level deeper. Update the config to:

    [Unit]
    Description=gunicorn daemon
    After=network.target
    
    [Service]
    User=muiruri_samuel
    Group=www-data
    WorkingDirectory=/home/muiruri_samuel/webapp/revamp
    ExecStart=/home/muiruri_samuel/webapp/djangoenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/muiruri_samuel/webapp/revamp/revamp.sock revamp.wsgi:application
    
    [Install]
    WantedBy=multi-user.target
    
  2. Reload systemd and restart Gunicorn
    Systemd needs to pick up the config change, so run these commands:

    sudo systemctl daemon-reload
    sudo systemctl restart gunicorn
    
  3. Verify the service status
    Check if the service is now running properly:

    sudo systemctl status gunicorn
    

Why this works:

When Gunicorn starts, it uses the WorkingDirectory as its base path. Your revamp.wsgi module lives inside /home/muiruri_samuel/webapp/revamp/revamp/—so by setting the working directory to /home/muiruri_samuel/webapp/revamp, Gunicorn can properly locate the revamp Python package (which contains wsgi.py) when it tries to import revamp.wsgi.

Quick double-check: Make sure the /home/muiruri_samuel/webapp/revamp/revamp directory has an __init__.py file (it should be there by default if you created the Django project with startproject). This file tells Python that the directory is a valid importable package.

内容的提问来源于stack exchange,提问作者Samuel Muiruri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:57:42