Can't load mod_wsgi compiled for Python 3

邮差的信 提交于 2019-12-01 11:50:41

That means that the library libpython3.5m.so.1.0 can't be found at runtime because the directory /opt/anaconda/anaconda3/lib is not a place where the dynamic linker would look for it.

You can try to rebuild mod_wsgi using:

./configure LDFLAGS='-Wl,-rpath=/opt/anaconda/anaconda3/lib' --with-python=/opt/anaconda/anaconda3/bin/python

That will save the library path within the generated binary.

The other option would be to set the LD_LIBRARY_PATH environment variable for the apache process, which is not really a good method.
Or add the directory /opt/anaconda/anaconda3/lib to the library search path using a conf file in /etc/ld.so.conf.d/, that would be a global setting tough. See man ld-linux for more info.

Also, don't forget to correctly set the WSGIPythonHome directive in your config file.


edit:

I've done some experimenting and I could reproduce your second error message when the python3 binary is not found on the PATH.
In that case it seems setting the WSGIPythonHome directive is not enough, you need to set the PYTHONHOME environment variable before apache is started, or change PATH so the interpreter can be found. On CentOS changing /etc/sysconfig/httpd should do the trick, just add:

export PYTHONHOME=/opt/anaconda/anaconda3
# alternatively this should also work:
export PATH="$PATH:/opt/anaconda/anaconda3/bin"

Or create a symlink to the interpreter in a directory on the path, e.g. /usr/local/bin...
For reference, an extended explanation why this is needed can be found here

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!