我正在使用 Ubuntu 16.04.2 LTS。
我一直在跟随一个指南 How To Set Up uWSGI and Nginx to Serve Python Apps on Ubuntu 14.04 .设置 virtualenv 后,我将按照说明进行操作:
pip install uwsgi
You can verify that it is now available by typing:
uwsgi --version
If it returns a version number, the uWSGI server is available for use.
但是,当我这样做时,我得到:
uwsgi: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
如果我继续并通过指南进一步工作,当我尝试使用 uwsgi 时,事情就会失败。
我的研究告诉我 PCRE 是 Perl 兼容的正则表达式,并且有几个人在线询问了 libpcre.so.1 与其他应用程序的问题。
例如对 similar issue relating to nginx 的响应:
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.
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
。就像这个 example .我已尝试发布所有内容但一无所获。
我认为我的主要问题是我不太了解问题或如何做上面 nginx 示例中提到的事情。
如有任何见解或指导,我们将不胜感激。
最佳答案
尽管我的上下文可能有所不同,但以下步骤也应该对您有所帮助。
我做了pip install uwsgi
进入我由 conda create -yn <env_name> python
创建的环境.请注意,甚至不需要将 PCRE 安装到环境中,因为它包含在 Anaconda
中。 .我们可以在环境中看到这个问题,在 source activate <env_name>
之后:
# uwsgi --version
uwsgi: error while loading shared libraries: libpcre.so.1: cannot open...
通过 root/sudo 访问,您可以找到 libpcre.so.1
的位置是/将是:
# find / -name libpcre.so.1
/opt/anaconda3/lib/libpcre.so.1
现在让 Linux 知道如何访问它:
# ldconfig /opt/anaconda3/lib/
这就是让它工作所需的一切。您可以看到您所做的更改:
# 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
作为
# LD_LIBRARY_PATH=/opt/anaconda3/lib uwsgi --version
关于linux - 设置 WSGI 应用程序时的 PCRE 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43301339/