我如何 运行 python-rq rqworker 作为 python 3 中 UWSGI 的附加守护进程而没有 ASCII 编码错误?

How can I run a python-rq rqworker as an attached-daemon in UWSGI in python 3 without ASCII encoding errors?

我正在尝试 运行 rqworker 作为 UWSGI 中的附加守护进程。为此,我在 config.ini 文件中添加:

attach-daemon = /path/to/rqworker

然后 UWSGI 尝试在应该启动 rqworker 时启动,但我在日志中收到以下错误:

RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Either switch to Python 2 or consult http://click.pocoo.org/python3/ for mitigation steps.

我可以从 bash 运行 rqworker 正常,但似乎没有为守护进程正确设置编码。

来自该消息中的链接页面:

You are dealing with an environment where Python 3 thinks you are restricted to ASCII data. The solution to these problems is different depending on which locale your computer is running in.

For instance, if you have a German Linux machine, you can fix the problem by exporting the locale to de_DE.utf-8:

export LC_ALL=de_DE.utf-8 export LANG=de_DE.utf-8 If you are on a US machine, en_US.utf-8 is the encoding of choice. On some newer Linux systems, you could also try C.UTF-8 as the locale:

export LC_ALL=C.UTF-8 export LANG=C.UTF-8

要在 UWSGI config.ini 文件中设置编码,您可以使用 "env" 设置环境变量,进而设置语言环境。在美国机器上,此配置可以工作:

env = LC_ALL=en_US.utf-8
env = LANG=en_US.utf-8
attach-daemon = /path/to/rqworker

在其他机器上,可以使用各种其他编码。