1

I'm attempting to run a flask app with mod_wsgi on Ubuntu 16.04. I'm having a problem setting the $LD_LIBRARY_PATH$ environment variable. I'm able to set this in my ~.bashrc file, and as a result I am able to import all my libraries and dependencies without a problem. However it seems apache seems to erase these environment variables.

The error I'm getting in my log file is the following

ImportError: libmkl_rt.so: cannot open shared object file: No such file or directory

There are two python libraries I'm importing that require mkl. The first doesn't seem to complain. However the second library cannot be imported due to the mkl error.

I find this odd so I recompiled the second python library after setting the $LD_RUN_PATH environment variable to the mkl paths. However it is still unable to find mkl.

How do I configure apache accordingly? All other imports work fine. I am able to run the flask scripts on their own without apache, so I'm pretty sure this is an apache problem.

user3543300
  • 499
  • 2
  • 9
  • 27
  • If you are confident you set ``LD_RUN_PATH`` correctly when compiling any libraries or Python modules which needed ``libmk_rt.so`` and ``ldd`` on those binaries show it being correctly found without having ``LD_LIBRARY_PATH`` being set, the problem may be that the library or directory it is in may not be readable to the user that Apache runs your code as. – Graham Dumpleton Feb 02 '17 at 08:15
  • I ran ldd on the library and the mkl library path showed up. What does this mean? – user3543300 Feb 02 '17 at 19:20
  • I actually realized I'm having import errors on other libraries as well. It seems as though apache can't find many other python libraries. – user3543300 Feb 02 '17 at 20:20

2 Answers2

4

if in you

/etc/sysconfig/httpd

add something like this

LD_LIBRARY_PATH=/my/library/path

then

apachectl restart httpd

should do the trick

fliman
  • 83
  • 5
3

apache by default use system lib path. so just add link of your so file to /usr/lib and then run command sudo ldconfig. perhaps problem will resolve

also this post may be helpful https://stackoverflow.com/a/23244452/6876911

Community
  • 1
  • 1
sahama
  • 669
  • 8
  • 16