8

I am working with Ubuntu 16.04.2 LTS.

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

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

However when I do this I get:

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

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

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.

For example a response to a 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.

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.

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.

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Rory
  • 81
  • 1
  • 4
  • It's usually supplied by libpcre3 (pcre e.g. version 8.39) but not included in Debian/Ubuntu packages. Neither in old versions. The easy way is to compile pcre3_8.39.orig.tar.bz2 http://packages.ubuntu.com/yakkety/libpcre3 and copy `libpcre.so.1.2.7` to /usr/lib/, and make the links libpcre.so.1, libpcre.so . Or make a "compat" package.deb libpcre1 with the files. – Knud Larsen Apr 09 '17 at 03:17
  • Please edit your above post to include OS name, version, architecture. Like Debian Jessie - amd64, Ubuntu 16.04 - i386 , etc. – Knud Larsen Apr 09 '17 at 03:36
  • Did you resolve the issue? I'm struggling with your exact problem right now. – Sebastiaan Oct 12 '17 at 14:15

1 Answers1

9

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

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...

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

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 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
wick
  • 1,995
  • 2
  • 20
  • 31
  • It worked. Does this mean I have to type LD_LIBRARY_PATH=/opt/anaconda3/lib before uwsgi everytime i use uwsgi – Aseem Mar 28 '19 at 19:14