openstackopenstack-horizon

Target WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi.py' cannot be loaded as Python module


I'm deploying openstack Stein with Ubuntu pro 18.04 LTS.

I deployed Horizon service on controller node in order to dashboard all Openstack components using this article

But when requesting apache2 http server. I cope with this error message :

500 Internal Server Error

When opening the apache2 logs file :

cat /var/log/apache2/error.log

I find the following :

[Sun May 09 13:13:38.406476 2021] [mpm_event:notice] [pid 20423:tid 140376496065472] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 13:13:38.407099 2021] [core:notice] [pid 20423:tid 140376496065472] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 13:13:43.003464 2021] [mpm_event:notice] [pid 20423:tid 140376496065472] AH00493: SIGUSR1 received.  Doing graceful restart
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 10.0.0.4. Set the 'ServerName' directive globally to suppress this message
[Sun May 09 13:13:43.011960 2021] [mpm_event:notice] [pid 20423:tid 140376496065472] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 13:13:43.011977 2021] [core:notice] [pid 20423:tid 140376496065472] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 13:17:46.415685 2021] [mpm_event:notice] [pid 20423:tid 140376496065472] AH00491: caught SIGTERM, shutting down
[Sun May 09 13:17:46.468567 2021] [mpm_event:notice] [pid 21198:tid 139990706088896] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 13:17:46.468646 2021] [core:notice] [pid 21198:tid 139990706088896] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 13:21:29.390499 2021] [mpm_event:notice] [pid 21198:tid 139990706088896] AH00491: caught SIGTERM, shutting down
[Sun May 09 13:21:49.634226 2021] [mpm_event:notice] [pid 1255:tid 140256812567488] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 13:21:49.659254 2021] [core:notice] [pid 1255:tid 140256812567488] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 13:23:59.045495 2021] [mpm_event:notice] [pid 1255:tid 140256812567488] AH00493: SIGUSR1 received.  Doing graceful restart
[Sun May 09 13:23:59.426244 2021] [mpm_event:notice] [pid 1255:tid 140256812567488] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 13:23:59.426259 2021] [core:notice] [pid 1255:tid 140256812567488] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 13:24:13.239708 2021] [mpm_event:notice] [pid 1255:tid 140256812567488] AH00493: SIGUSR1 received.  Doing graceful restart
[Sun May 09 13:24:13.246379 2021] [mpm_event:notice] [pid 1255:tid 140256812567488] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 13:24:13.246398 2021] [core:notice] [pid 1255:tid 140256812567488] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 13:27:25.458793 2021] [mpm_event:notice] [pid 1255:tid 140256812567488] AH00491: caught SIGTERM, shutting down
[Sun May 09 13:27:25.517766 2021] [mpm_event:notice] [pid 2855:tid 140136656354240] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 13:27:25.517896 2021] [core:notice] [pid 2855:tid 140136656354240] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 13:43:29.758680 2021] [mpm_event:notice] [pid 2855:tid 140136656354240] AH00493: SIGUSR1 received.  Doing graceful restart
[Sun May 09 13:43:31.269009 2021] [mpm_event:notice] [pid 2855:tid 140136656354240] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 13:43:31.269046 2021] [core:notice] [pid 2855:tid 140136656354240] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 13:46:08.093465 2021] [mpm_event:notice] [pid 2855:tid 140136656354240] AH00491: caught SIGTERM, shutting down
[Sun May 09 13:46:08.158907 2021] [mpm_event:notice] [pid 4869:tid 139664207449024] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 13:46:08.159030 2021] [core:notice] [pid 4869:tid 139664207449024] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 14:52:45.196411 2021] [mpm_event:notice] [pid 4869:tid 139664207449024] AH00493: SIGUSR1 received.  Doing graceful restart
[Sun May 09 14:52:48.224709 2021] [mpm_event:notice] [pid 4869:tid 139664207449024] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 14:52:48.224752 2021] [core:notice] [pid 4869:tid 139664207449024] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 15:06:37.695556 2021] [mpm_event:notice] [pid 4869:tid 139664207449024] AH00493: SIGUSR1 received.  Doing graceful restart
[Sun May 09 15:06:39.207131 2021] [mpm_event:notice] [pid 4869:tid 139664207449024] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 15:06:39.207172 2021] [core:notice] [pid 4869:tid 139664207449024] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 15:10:05.835601 2021] [mpm_event:notice] [pid 4869:tid 139664207449024] AH00491: caught SIGTERM, shutting down
[Sun May 09 15:10:42.512223 2021] [mpm_event:notice] [pid 1371:tid 140201303968704] AH00489: Apache/2.4.29 (Ubuntu) mod_wsgi/4.5.17 Python/3.6 configured -- resuming normal operations
[Sun May 09 15:10:42.785301 2021] [core:notice] [pid 1371:tid 140201303968704] AH00094: Command line: '/usr/sbin/apache2'
[Sun May 09 15:20:22.791837 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268] mod_wsgi (pid=1379): Target WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi.py' cannot be loaded as Python module.
[Sun May 09 15:20:22.791908 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268] mod_wsgi (pid=1379): Exception occurred processing WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi.py'.
[Sun May 09 15:20:22.793946 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268] Traceback (most recent call last):
[Sun May 09 15:20:22.793991 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]   File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi.py", line 29, in <module>
[Sun May 09 15:20:22.793998 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]     application = get_wsgi_application()
[Sun May 09 15:20:22.794004 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]   File "/usr/lib/python3/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Sun May 09 15:20:22.794007 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]     django.setup(set_prefix=False)
[Sun May 09 15:20:22.794013 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]   File "/usr/lib/python3/dist-packages/django/__init__.py", line 22, in setup
[Sun May 09 15:20:22.794017 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Sun May 09 15:20:22.794022 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]   File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 56, in __getattr__
[Sun May 09 15:20:22.794026 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]     self._setup(name)
[Sun May 09 15:20:22.794031 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]   File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 41, in _setup
[Sun May 09 15:20:22.794034 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]     self._wrapped = Settings(settings_module)
[Sun May 09 15:20:22.794040 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]   File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 137, in __init__
[Sun May 09 15:20:22.794044 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268]     raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
[Sun May 09 15:20:22.794062 2021] [wsgi:error] [pid 1379:tid 140201173231360] [remote XXX.XXX.XXX.XXX:44268] ValueError: Incorrect timezone setting: UTC+01:00
[Sun May 09 15:21:39.911979 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061] mod_wsgi (pid=1378): Target WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi.py' cannot be loaded as Python module.
[Sun May 09 15:21:39.912056 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061] mod_wsgi (pid=1378): Exception occurred processing WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi.py'.
[Sun May 09 15:21:39.912508 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061] Traceback (most recent call last):
[Sun May 09 15:21:39.912563 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]   File "/usr/share/openstack-dashboard/openstack_dashboard/wsgi.py", line 29, in <module>
[Sun May 09 15:21:39.912568 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]     application = get_wsgi_application()
[Sun May 09 15:21:39.912574 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]   File "/usr/lib/python3/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Sun May 09 15:21:39.912577 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]     django.setup(set_prefix=False)
[Sun May 09 15:21:39.912582 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]   File "/usr/lib/python3/dist-packages/django/__init__.py", line 22, in setup
[Sun May 09 15:21:39.912585 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Sun May 09 15:21:39.912590 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]   File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 56, in __getattr__
[Sun May 09 15:21:39.912593 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]     self._setup(name)
[Sun May 09 15:21:39.912598 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]   File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 41, in _setup
[Sun May 09 15:21:39.912601 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]     self._wrapped = Settings(settings_module)
[Sun May 09 15:21:39.912626 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]   File "/usr/lib/python3/dist-packages/django/conf/__init__.py", line 137, in __init__
[Sun May 09 15:21:39.912629 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061]     raise ValueError("Incorrect timezone setting: %s" % self.TIME_ZONE)
[Sun May 09 15:21:39.912645 2021] [wsgi:error] [pid 1378:tid 140201190016768] [remote XXX.XXX.XXX.XXX:40061] ValueError: Incorrect timezone setting: UTC+01:00

For the wsgi.py file, this is the content :

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
WSGI config for openstack_dashboard project.
"""

import os
import sys

from django.core.wsgi import get_wsgi_application

# Add this file path to sys.path in order to import settings
sys.path.insert(0, os.path.normpath(os.path.join(
    os.path.dirname(os.path.realpath(__file__)), '..')))
os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_dashboard.settings'
sys.stdout = sys.stderr

application = get_wsgi_application()

What is the fix ?


Solution

  • Finaly, it works. I had to change timezone setting into string ... see article (Continent/City)