简体   繁体   English

由于导入模块错误,无法启动gunicorn.service

[英]Unable to start gunicorn.service due to import module error

I am trying to start Gunicorn from systemd service file, but I get import module error. 我正在尝试从systemd服务文件启动Gunicorn,但出现导入模块错误。 How can I fix it? 我该如何解决?

My gunicorn service file: 我的gunicorn服务档案:

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
ExecStart=/home/sammy/myproject/venv/bin/gunicorn --workers 3 --bind unix:/home/sammy/myproject/myproject.sock myproject.wsgi:application

[Install]
WantedBy=multi-user.target

When I execute gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application , there is no error. 当我执行gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application ,没有错误。

But when I use 但是当我使用

sudo systemctl start gunicorn
sudo systemctl enable gunicorn

I get this error: 我收到此错误:

ImportError: No module named 'myproject'

What is wrong? 怎么了?

It is probably a directory permission problem. 这可能是目录权限问题。 Make sure the user sammy is in the www-data group and set the home directory permissions with a chmod 710. 确保用户sammy位于www-data组中,并使用chmod 710设置主目录权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法启动 gunicorn.service:未找到单位 gunicorn.service。 乌本托 18.04 - Failed to start gunicorn.service: Unit gunicorn.service not found. Ubunto 18.04 Gunicorn.service 无法读取 Python3.6 库 - Gunicorn.service unable to read Python3.6 library 无法启动 gunicorn.service:gunicorn.socket 的作业失败。 乌本托 18.04 - Failed to start gunicorn.service: Job for gunicorn.socket failed . Ubunto 18.04 在 Centos 8 上部署 Django 项目,使用 Gunicorn,Nginx(Gunicorn.service 问题) - Deploying Django project on Centos 8, using Gunicorn, Nginx (Gunicorn.service problem) 如何为Django项目存储除gunicorn.service内的环境变量? - How to store env variables other than inside gunicorn.service for a Django project? 由于'INFO spawnerr:'app_name'的调度程序未知错误,因此无法启动nohup服务:EACCES' - Unable to start service with nohup due to 'INFO spawnerr: unknown error making dispatchers for 'app_name': EACCES' heroku上的gunicorn导入错误 - gunicorn import error on heroku gunicorn 服务器启动时出错 - Error with gunicorn server start 不支持Gunicorn按文件名导入(模块) - Gunicorn Import by filename is not supported (module) 由于 gunicorn AppImportError,应用程序无法启动 - Application won't start due to gunicorn AppImportError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM