django - 获取 pkg_resources.DistributionNotFound: 'supervisor==3.2.0' 分发未找到并且是应用程序需要的?
问题描述
尝试通过主管运行 gunicorn 脚本时出错。gunicorn 脚本在直接运行时运行良好。我在 ubuntu 16.04 主管版本:获取
pkg_resources.DistributionNotFound: The 'supervisor==3.2.0' distribution was not found and is required by the application
在跑步的时候
sudo supervisorctl reread
我运行 Django 应用程序的 gunicron 脚本:
#!/bin/bash
NAME="applicant_screening" # Name of the application
DJANGODIR=/home/applicant-screening-system/screening_backend # Django project directory
#SOCKFILE=/home/track_ip/run/gunicorn.sock # we will communicte using this unix socket
USER=root # the user to run as
#GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=screening_backend.settings # which settings file should Django use
DJANGO_WSGI_MODULE=screening_backend.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
source /home/screen-env/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER \
--bind=0.0.0.0:8000 \
--log-level=debug \
--log-file=-
解决方案
这是supervisor的要求和安装的python版本不匹配。为此,您需要:
安装 Python 2.7。(由于 supervisor 支持 2.* 并且对 3.* 的支持仍在开发中) https://askubuntu.com/a/981279
转到 /usr/bin/supervisorctl 文件。
将第一行更新为
!/usr/bin/python2
让主管使用安装的 python 2.7 而不是 python3。
- 重新运行 supervisorctl 命令。
推荐阅读
- javascript - Vue.js:如何在选择下拉框中获取选项的属性?
- node.js - 合并没有重复的数组 | 节点 | 蒙哥达
- javascript - 元素未在画布上呈现
- docker - Docker 容器不回复主机中的客户端应用程序
- powerbi - 按不同级别聚合时的测量误差
- tfs - 可以使用 GIT 访问哪些 TFS 2018 存储库?
- ios - 如何在 React Native 的 Alert 组件中添加 Star Rating?
- aws-lambda - 参数 ScheduleExpression 无效 - AWS Lambda 触发器计划
- python - 如何用空值替换动态正则表达式?
- amazon-web-services - 如何在 AWS Sagemaker 上部署朴素贝叶斯模型