Python在CentOS中编译uwsgi时提示pcre函数找不到如何解决

routing.c:(.text+0x366c): undefined reference to `pcre_free_study'

routing.c:(.text+0x3690): undefined reference to `pcre_free_study'

collect2: ld returned 1 exit status

*** error linking uWSGI ***

make: *** [all] Error 1

[[email protected]]# rpm -qa | grep pcre

pcre-devel-7.8-7.el6.x86_64

pcre-7.8-7.el6.x86_64

编译时候又没法设置 prefix 之类 好气啊。。 求大大帮忙看看。。

centos 系统


Python在CentOS中编译uwsgi时提示pcre函数找不到如何解决

15 回复

在CentOS上编译uWSGI时遇到PCRE函数未找到的错误,通常是因为系统缺少PCRE的开发头文件和库文件。PCRE(Perl Compatible Regular Expressions)是uWSGI用于路由匹配的依赖。

解决方案:

  1. 安装PCRE开发包

    sudo yum install pcre-devel
    
  2. 重新编译uWSGI: 确保在安装开发包后重新运行uWSGI的编译安装过程:

    python setup.py build
    sudo python setup.py install
    

    或者使用pip:

    pip install uwsgi --no-cache-dir
    

如果问题仍然存在

  • 检查PCRE库路径是否在标准位置(如/usr/lib/usr/lib64)。
  • 可以尝试手动指定PCRE路径:
    export PCRE_INCLUDEDIR=/usr/include/pcre
    export PCRE_LIBDIR=/usr/lib64
    pip install uwsgi --no-cache-dir
    

一句话总结:安装pcre-devel开发包就能解决。

高人,怼人就得有这种气势

嘛,怼人也得讲究基本法,我确定 Google 能搜到才会放这种链接,免得被人说“根本搜不到嘛”

囧。。鱼摆摆这两天被封了 所以。。。暂时还没找到合适的 vpn

哈哈,这个好,收藏了。

我 Python 项目都是用 docker 部署的,服务器都是用 ubuntu,爱莫能助了

pip install uwsgi
Collecting uwsgi
Using cached uwsgi-2.0.15.tar.gz
Installing collected packages: uwsgi
Running setup.py install for uwsgi … done
Successfully installed uwsgi-2.0.15


# uwsgi --version
2.0.15

# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.3.1611 (Core)
Release: 7.3.1611
Codename: Core

# rpm -qa | grep pcre
pcre-devel-8.32-15.el7_2.1.x86_64
pcre-8.32-15.el7_2.1.x86_64


centos 搞 uwsgi 不是一键安装吗?

centos 下确实可以一键安装 但是 pip 安装时候其实也有中途编译、链接的过程 如果有些依赖缺失一样会报错的。。
我的服务器是新机器 上面干干净净 所以会不断报错 不断安装各种库和 devel。。

我们也在逐步切换到 docker。。 同样感谢~

其实 Gunicorn 的性能也不差,部署起来超级简单的,为什么不用这个呢?而且你觉得性能还需要提升还可以将 Gunicorn 自带的 worker 换掉,换成 bjoern 或者 meinheld

不是性能问题

gunicorn 自带 self-healing 功能嘛
gunicorn 可以检测内存溢出自动重启 worker 嘛
gunicorn 可以 worker 失去响应自动重启 worker 嘛
gunicorn 自带各种姿势日志输出极自动 rotate 功能嘛
gunicorn 自带集群管理动态增删 worker 功能嘛


等等

我可以列 1000 条。


uwsgi 的运维、配置都比 gunicorn 简单。但是 uwsgi 那个配置文档直接把初学者吓尿了。。。。

我的也是新机器,阿里云的 centos 版,之前只用 yum 安装过一个 nginx 和 php,没装过其它东西。你新机器为何要用 centos6 不用 7 呢?不是给自己找麻烦么。

萝卜青菜各有所好。我只是觉得极大多数情况 Gunicorn 都是够用的。
比如我之前负责的项目,压根就不需要应用自动 rotate 日志,日志都是 syslog 跟 elk 做的。

够用是够用了,但是用的不爽。

回到顶部