loris-imageserver / loris

Loris IIIF Image Server
Other
208 stars 87 forks source link

WSGI error in Ubuntu 20.04 installation #533

Closed ewg118 closed 3 years ago

ewg118 commented 3 years ago

I am installing the latest Loris release in Ubuntu 20.04, running Python 3.8 and Apache 2.4.46. I am getting a 500 Internal Server error. The Apache error log is as follows:

[Mon Apr 19 16:40:23.570372 2021] [wsgi:error] [pid 300289:tid 140299556169472] [remote 216.30.189.61:59818] mod_wsgi (pid=300289): Failed to exec Python script file '/var/www/loris/loris.wsgi'.
[Mon Apr 19 16:40:23.573086 2021] [wsgi:error] [pid 300289:tid 140299556169472] [remote 216.30.189.61:59818] mod_wsgi (pid=300289): Exception occurred processing WSGI script '/var/www/loris/loris.wsgi'.
[Mon Apr 19 16:40:23.573161 2021] [wsgi:error] [pid 300289:tid 140299556169472] [remote 216.30.189.61:59818] Traceback (most recent call last):
[Mon Apr 19 16:40:23.573226 2021] [wsgi:error] [pid 300289:tid 140299556169472] [remote 216.30.189.61:59818]   File "/var/www/loris/loris.wsgi", line 2, in <module>
[Mon Apr 19 16:40:23.573315 2021] [wsgi:error] [pid 300289:tid 140299556169472] [remote 216.30.189.61:59818]     from loris.webapp import create_app
[Mon Apr 19 16:40:23.573380 2021] [wsgi:error] [pid 300289:tid 140299556169472] [remote 216.30.189.61:59818] ImportError: No module named loris.webapp

The loris.wsgi file is present in /var/www/loris, and Apache should have execute permissions. The contents of the file are:

#!/usr/bin/env python
from loris.webapp import create_app
# Uncomment and configure below if you are using virtualenv
# import site
# site.addsitedir('/path/to/my/virtualenv/lib/python2.x/site-packages')
application = create_app(config_file_path='/usr/local/lib/python3.8/dist-packages/Loris-3.2.1-py3.8.egg/loris/data/loris.conf')

The loris.conf exists, and looks fine to me. I've installed Loris 2 on Python 2.7 on another server years ago, and didn't have any errors at the time. The Apache error seems pretty non-specific. I'm not sure why it can't find loris.webapp.

Thanks for your help.

regisrob commented 3 years ago

It may be related to #435, but not really sure... What I always had to do on Debian is to tweak loris.wsgi this way:

#!/usr/bin/env python
#from loris.webapp import create_app
# Uncomment and configure below if you are using virtualenv
import site
site.addsitedir('/opt/virtualenvs/py3.7/lib/python3.7/site-packages')
from loris.webapp import create_app
application = create_app(config_file_path='/opt/virtualenvs/py3.7/lib/python3.7/site-packages/Loris-3.2.1-py3.7.egg/loris/data/loris.conf')

Hope that will help!

ewg118 commented 3 years ago

I've followed instructions on creating a virtual environment in Ubuntu 20.04, but it doesn't seem to have done anything.

regisrob commented 3 years ago

No other idea... Are you using libapache2-mod-wsgi-py3?

ewg118 commented 3 years ago

That's it. Only libapache2-mod-wsgi was installed for Python 2.x, as per the instructions on the Apache wiki page. Thanks