gpt4 book ai didi

python - 如何在 Ubuntu 的虚拟环境中为 uwsgi 安装 gevent 插件?

转载 作者:太空宇宙 更新时间:2023-11-03 14:35:02 30 4
gpt4 key购买 nike

我在 ubuntu 16.04 中运行 uWSGI (2.0.16)

当我从 root 运行 uWSGI 时,它工作正常。但是,当我开始在虚拟环境中运行 uWSGI 时,会出现以下错误:-

uwsgi: unrecognized option '--gevent'
getopt_long() error

然后我在我的虚拟环境中检查uWSGI的插件列表,发现缺少gevent插件。

根据 uWSGI >= 1.4 的 uWSGI 文档

The gevent plugin is compiled in by default when the default profile is used. Doing the following will install the python plugin as well as the gevent one:

pip install uwsgi

但是通过pip install uwsgi安装uwsgi,仍然无法在虚拟环境中获取gevent插件。但是,以类似的方式,当我在虚拟环境之外安装 uwsgi 时,gevent 插件已经可用。

我已经尝试安装uwsgi-plugin-gevent-python

我必须构建支持 SSL 的 uwsgi,所以我使用 CFLAGS 来构建 uWSGI。 ssl 支持在我的虚拟环境中也不起作用。

最佳答案

由于这个问题在“uwsgi build plugin gevent support”的许多变体中排名很高,我认为它可以使用一个答案。

您可以通过运行以下命令验证 uwsgi 是否正在加载 gevent 插件:

$ uwsgi --plugins-list

如果 gevent 没有在 *** uWSGI loaded generic plugins *** 部分中列出,那么你可以编译它,下面是你如何做到这一点python 3.4(我在这里使用的是 Ubuntu 14.04):

$ PYTHON=/usr/bin/python3.4 uwsgi --build-plugin "$UWSGI_DIR/plugins/gevent gevent34"

UWSGI_DIR 是您的 uwsgi 安装目录路径。

如果您遇到如下错误:

fatal error: Python.h: No such file or directory
#include <Python.h>

您可能缺少 python3-dev 工具,在 Ubuntu 中,您可以使用以下方式安装这些工具:

$ apt-get install python3-dev

然后重新运行构建插件命令。

如果您没有收到错误,您现在应该在 UWSGI_DIR 中有一个名为 gevent34_plugin.so 的插件。您现在可以在启动时加载它:

$ uwsgi --plugins-dir $UWSGI_DIR --plugin gevent34 --plugins-list

gevent应该列在*** uWSGI loaded generic plugins ***部分。

关于python - 如何在 Ubuntu 的虚拟环境中为 uwsgi 安装 gevent 插件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48759992/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com