python - 没有名为“gunicorn”的模块
问题描述
我正在尝试使用 gunicorn 和 nginx 为 Flask 服务这是我的 systemd 单元配置文件
[Unit]
Description=Gunicorn instance to serve odooErp
After=network.target
[Service]
User=tito
Group=www-data
WorkingDirectory=/home/tito/peg/odoo_api/peg_api
Environment="PATH=/home/tito/peg/odoo_api/peg_api/env/bin"
ExecStart=/home/tito/peg/odoo_api/peg_api/env/bin/gunicorn --workers 3 --bind unix:odooErp.sock -m 007 wsgi:app
[Install]
WantedBy=multi-user.target
当我启动服务时,尽管使用 pip 安装了 gunicorn,但我遇到了以下错误
[0;1;31m●[0m odooErp.service - Gunicorn instance to serve productionOdoo
Loaded: loaded (/etc/systemd/system/odooErp.service; enabled; vendor preset: enabled)
Active: [0;1;31mfailed[0m (Result: exit-code) since Tue 2020-08-18 05:33:23 UTC; 1min 0s ago
Main PID: 18305 (code=exited, status=1/FAILURE)
CPU: 43ms
Aug 18 05:33:23 peg-test-01 systemd[1]: Started Gunicorn instance to serve odooErp.
Aug 18 05:33:23 peg-test-01 gunicorn[18305]: Traceback (most recent call last):
Aug 18 05:33:23 peg-test-01 gunicorn[18305]: File "/home/tito/peg/odoo_api/peg_api/env/bin/gunicorn", line 7, in <module>
Aug 18 05:33:23 peg-test-01 gunicorn[18305]: from gunicorn.app.wsgiapp import run
Aug 18 05:33:23 peg-test-01 gunicorn[18305]: ImportError: No module named 'gunicorn'
Aug 18 05:33:23 peg-test-01 systemd[1]: [0;1;39modooErp.service: Main process exited, code=exited, status=1/FAILURE[0m
Aug 18 05:33:23 peg-test-01 systemd[1]: [0;1;39modooErp.service: Unit entered failed state.[0m
Aug 18 05:33:23 peg-test-01 systemd[1]: [0;1;39modooErp.service: Failed with result 'exit-code'.[0m
解决方案
这可能是因为模块不在正确的路径中
如果你在windows上,你可以在你的环境中设置如下路径:在左下角搜索这台电脑>属性>高级系统设置>右下角的环境变量>在用户变量中单击PATH然后新建并设置路径
推荐阅读
- ionic4 - ion-datetime displayFormat 如何在 ionic4 中转义文字?
- python - 更改键名并添加相同键的值
- python - pymongo 查询使我的烧瓶服务器停止运行
- python - 如何在 Python 中将十六进制值列表转换为十六进制字符串?
- reactjs - 如何将 create-react-app 转换为 Preact?
- twilio - 如何将传入消息发送到 flex 并调用函数?将 2 个动作连接到 1 个触发器
- android - 如何在可滚动活动中的 ListView 下方放置一个按钮?
- keras - 如何在 Tensorboard 中可视化度量回调?
- powershell - 如何使用管道在 Rundeck 中运行 Powershell 命令
- apache - 基于查询字符串查找的 Apache httpd 重写 url