Why is wsgi looking for a library in /lib64 when the correct version is in the python distribution
Copy all the files libz.so* to any path in your LD_LIBRARY_PATH
Short story long, I have miniconda and stuck at the same issue. I realised that conda prefer to search for library in LD_LIBRARY_PATH than its own libs.
Hence, you need to make missing library available in LD_LIBRARY_PATH, adding the whole conda lib directory to LD_LIBRARY_PATH never a good idea (i.e. it just breaks your whole system). 
As a result, copy appropriate lib from conda library to any folder in your LD_LIBRARY_PATH is best solution.
Note the path must show up before /lib64 in your LD_LIBRARY_PATH (i.e. export LD_LIBRARY_PATH=/your/path:$LD_LIBRARY_PATH)
I've created a flask application that I'm trying to deploy on an apache server. I've installed a conda distribution of python where I've downloaded associated modules, including flask, matplotlib and others. I'm using wsgi to launch the application.
The problem I'm having is when the server runs wsgi script it fails saying that when trying to import matplotlib it can't find the correct version libz

ImportError: /lib64/libz.so.1: version `ZLIB_1.2.3.4' not found (required by /mypath/miniconda/lib/python2.7/site-packages/matplotlib/../../.././libpng16.so.16)

However the correct version of libz is found at /mypath/miniconda/lib/libz.*
The wsgi module was built with this version of python. In addition the apache init script sets the PATH environment variable this location of python (and there are no other python 2.7 on the system). When I print the ldd path of libpng via the wsgi script it points to the python version of libz as the one it should be loading.

linux-vdso.so.1 =>  (0x00007fff9fe00000)
libz.so.1 => /mypath/miniconda/lib/python2.7/site-packages/matplotlib/../../../././libz.so.1 (0x00007fb2e4388000)
libm.so.6 => /lib64/libm.so.6 (0x00007fb2e40e8000)
libc.so.6 => /lib64/libc.so.6 (0x00007fb2e3d50000)
/lib64/ld-linux-x86-64.so.2 (0x00000035a9e00000)

so why is it trying to load from /lib64 ?? When I try load the module via the same python from a terminal, it loads fine. I understand my environment is not going to be the same as the apache environment but offhand I couldn't see any major differences.
I haven't tried explicitly setting the LD_LIBRARY_PATH or WSGIPythonHome, neither which seem like they should be necessary. But that's the next avenue I'll try. Even if that works (but especially if it doesn't), I'd be curious if anyone has any ideas as to what's going on.
Thanks in advance.