设置WSGI应用程序时出现PCRE问题 [英] PCRE issue when setting up WSGI application

查看:51
本文介绍了设置WSGI应用程序时出现PCRE问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ubuntu 16.04.2 LTS.

I am working with Ubuntu 16.04.2 LTS.

我一直在遵循指南如何设置uWSGI和Nginx以在Ubuntu 14.04上服务Python应用.设置virtualenv后,请按照说明进行操作:

I have been following a guide How To Set Up uWSGI and Nginx to Serve Python Apps on Ubuntu 14.04. Once I have set up the virtualenv I follow the instructions:

pip install uwsgi

您可以通过键入以下内容来验证它是否可用:

You can verify that it is now available by typing:

uwsgi --version

如果返回版本号,则可以使用uWSGI服务器.

If it returns a version number, the uWSGI server is available for use.

但是,当我这样做时,我会得到:

However when I do this I get:

uwsgi:加载共享库时出错:libpcre.so.1:无法打开共享对象文件:没有这样的文件或目录

uwsgi: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

如果我继续努力并逐步按照指南进行操作,那么尝试使用uwsgi时一切都会掉下去.

If I push on and work further through the guide things fall over when I try use uwsgi.

我的研究告诉我PCRE是Perl兼容的正则表达式,并且有很多人在线上问过libpcre.so.1与其他应用程序有关的问题.

My research tells me that PCRE is Perl Compatible Regular Expressions and several people have asked questions online with libpcre.so.1 issues with other applications.

例如,对

该消息表示其内容.Nginx可执行文件已编译为期望PCRE(与Perl兼容的正则表达式)共享库可以在LD_LIBRARY_PATH上的某个地方使用,或在/etc/ld.so.conf或任何等效的库定位机制适用于您的操作系统,但找不到该库.

The message means what it says. The nginx executable was compiled to expect the PCRE (Perl-compatible Regular Expression) shared library to be available somewhere on LD_LIBRARY_PATH or specified in /etc/ld.so.conf or whatever equivalent library-locating mechanisms apply to your operating system, and it cannot find the library.

您将需要安装PCRE-或配置您的环境,以便nginx将查找安装了PCRE的库.

You will need to install PCRE - or configure your environment so that nginx will look for the PCRE library where it is installed.

但是我发现与安装PCRE或配置它没有太大关系.大多数安装说明使用: apt-get install libpcre3 libpcre3-dev ,然后重新安装uwsgi pip install uwsgi -I .就像在示例中一样.我在哪里尝试过发布的所有内容,却一无所获.

But I can't find much relevant to installing PCRE or configuring it. Most install instructions use: apt-get install libpcre3 libpcre3-dev and then reinstalling uwsgi pip install uwsgi -I. As in this example. Where I have tried everything posted and got nowhere.

我认为我的主要问题是我对这个问题不太了解,或者对上面的nginx示例中提到的事情不太了解.

I think my principle issue is that I don't understand the problem very well or how to do the things mentioned in the nginx example above.

任何见解或指导将不胜感激.

Any insight or guidance would be much appreciated.

推荐答案

即使我的上下文可能有所不同,以下步骤也应为您提供帮助.

Even though my context may be different, the following steps should help you as well.

我在 conda create -yn< env_name>创建的环境中 pip安装了uwsgi .python .请注意,甚至 Anaconda 中都包含PCRE,因此甚至不需要将PCRE安装到环境中.在 source激活< env_name> 后,我们可以在环境中看到此问题:

I did pip install uwsgi into my environment created by conda create -yn <env_name> python. Note, that one wouldn't even need to install PCRE into the environment, because it is included with Anaconda. We can see this issue in the environment, after source activate <env_name>:

# uwsgi --version
uwsgi: error while loading shared libraries: libpcre.so.1: cannot open...

具有root/sudo访问权限,您可以找到 libpcre.so.1 的位置/将位于的位置:

With root/sudo access you can find where libpcre.so.1 is/will be:

# find / -name libpcre.so.1
/opt/anaconda3/lib/libpcre.so.1

现在让Linux知道如何访问它:

Now let Linux know how to access it:

# ldconfig /opt/anaconda3/lib/

这就是使它工作所需的全部.您可以看到所做的更改:

That's all you need to make it work. You can see the change you are making:

# find / -name uwsgi
/opt/anaconda3/envs/<env_name>/bin/uwsgi

# ldd -d /opt/anaconda3/envs/<env_name>/bin/uwsgi
        linux-vdso.so.1 =>  (0x00007fff2d1ba000)
        ...
        /lib64/ld-linux-x86-64.so.2 (0x00007ff98dbc5000)
undefined symbol: pcre_free     (/opt/anaconda3/envs/cts/bin/uwsgi)

PS 结果是上面的 ldconfig 填充了全局缓存/etc/ld.so.cache ,在我的情况下,它与系统冲突库(/lib/x86_64-linux-gnu/libdbus-1.so.3 ).因此,我不得不通过运行不带参数的 ldconfig 来还原更改,并求助于运行时链接=以

uwsgi 作为

PS Turned out ldconfig above populates global cache /etc/ld.so.cache, which, in my case, clashed with system library (/lib/x86_64-linux-gnu/libdbus-1.so.3). So I had to revert the change by running ldconfig without parameters and resort to runtime linking = starting uwsgi as

# LD_LIBRARY_PATH=/opt/anaconda3/lib uwsgi --version

这篇关于设置WSGI应用程序时出现PCRE问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆