1

我正在尝试通过 Wand 将 PDF 转换为 JPG/PNG。

这是代码(编辑)

os.path.isfile(os.path.join(settings.PROJECT_PATH, "file.pdf"):
    with Image(filename=os.path.join(settings.PROJECT_PATH, "file.pdf", resolution=100) as image:
        image.save(filename=os.path.join(settings.PROJECT_PATH, "file.jpg")

它可以在本地开发服务器、生产服务器上的开发服务器以及 manage.py shell(在生产服务器上)上完美运行。

但是,当通过我的生产主管/guncicorn 设置使用时,我收到以下错误

DelegateError at /finance/api/v1/receipt/
Postscript delegate failed `/webapps/bab/bab/Beenie-Man-1.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/677

这是启动脚本。

#!/bin/bash

NAME="bab"                                  # Name of the application
DJANGODIR=/webapps/bab/bab             # Django project directory
SOCKFILE=/webapps/bab/run/gunicorn.sock  # we will communicte using this unix socket
USER=bab                                        # the user to run as
GROUP=webapps                                     # the group to run as
NUM_WORKERS=1                                     # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=bab.settings             # which settings file should Django use
DJANGO_WSGI_MODULE=bab.wsgi                     # WSGI module name

echo "Starting $NAME as `whoami`"

# Activate the virtual environment
cd $DJANGODIR
source ../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 ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $NUM_WORKERS \
  --user=$USER --group=$GROUP \
  --log-level=debug \
  --bind=unix:$SOCKFILEchris@python:/webapps/bab$ 

当我在生产服务器上运行测试时,同时运行完整的调试服务器和 shell,它正在使用正确的用户帐户和正确的 virtualenv 运行(如果没有它,它根本不会工作)

可能是环境变量问题吗?还是某种许可?

4

0 回答 0