gpt4 book ai didi

python - Openshift 上的 Django - 500 内部服务器错误 - wsgi.py 中的错误

转载 作者:太空宇宙 更新时间:2023-11-04 03:17:48 26 4
gpt4 key购买 nike

我试图在 OpenShift 上部署我的 django 应用程序,但出了点问题,我不知道如何解决这个问题。

rhc tail -a myproject 的结果:(并且站点页面显示 500 Internal Server Error)

[Sat Feb 27 07:23:32 2016] [notice] SIGHUP received.  Attempting to restart
[Sat Feb 27 07:23:32 2016] [notice] Digest: generating secret for digest authentication ...
[Sat Feb 27 07:23:32 2016] [notice] Digest: done
[Sat Feb 27 07:23:32 2016] [notice] Apache/2.2.15 (Unix) mod_wsgi/3.4 Python/3.3.2 configured -- resuming normal operations
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] mod_wsgi (pid=506177): Target WSGI script '/var/lib/openshift/56d067420c1e664f0e0000da/app-root/runtime/repo/wsgi.py' can
not be loaded as Python module.
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] mod_wsgi (pid=506177): Exception occurred processing WSGI script '/var/lib/openshift/56d067420c1e664f0e0000da/app-root/ru
ntime/repo/wsgi.py'.
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] Traceback (most recent call last):
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] File "/var/lib/openshift/56d067420c1e664f0e0000da/app-root/runtime/repo/wsgi.py", line 10, in <module>
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] from myblog.wsgi import application
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] File "/var/lib/openshift/56d067420c1e664f0e0000da/app-root/runtime/repo/myblog/wsgi.py", line 12, in <module>
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] from django.core.wsgi import get_wsgi_application
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] File "/var/lib/openshift/56d067420c1e664f0e0000da/python/virtenv/venv/lib64/python3.3/site-packages/django/core/wsgi.py
", line 2, in <module>
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] from django.core.handlers.wsgi import WSGIHandler
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] File "/var/lib/openshift/56d067420c1e664f0e0000da/python/virtenv/venv/lib64/python3.3/site-packages/django/core/handler
s/wsgi.py", line 10, in <module>
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] from django import http
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] File "/var/lib/openshift/56d067420c1e664f0e0000da/python/virtenv/venv/lib64/python3.3/site-packages/django/http/__init_
_.py", line 2, in <module>
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] from django.http.request import (
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] File "/var/lib/openshift/56d067420c1e664f0e0000da/python/virtenv/venv/lib64/python3.3/site-packages/django/http/request
.py", line 10, in <module>
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] from django.core import signing
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] File "/var/lib/openshift/56d067420c1e664f0e0000da/python/virtenv/venv/lib64/python3.3/site-packages/django/core/signing
.py", line 51, in <module>
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] from django.utils.module_loading import import_string
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] File "/var/lib/openshift/56d067420c1e664f0e0000da/python/virtenv/venv/lib64/python3.3/site-packages/django/utils/module
_loading.py", line 67, in <module>
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] from importlib.util import find_spec as importlib_find
[Sat Feb 27 07:25:08 2016] [error] [client 127.5.163.1] ImportError: cannot import name find_spec
1.194.187.34 - - [27/Feb/2016:07:25:08 -0500] "GET / HTTP/1.1" 500 618 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safa
ri/537.36"

这是我第一次在 PaaS 平台 OpenShift 上部署我的应用程序。在此之前,我只是用centos(python3.5, django 1.9.2)在我的CVM上部署成功。

我的文件是这样放的:

myproject/
+---wsgi/
| +---static/
| +---.gitkeep
+---wsgi.py
+---setup.py
+---.openshift/
+---requirements.txt
+---myblog/
| +----__init__.py
| +----urls.py
| +----settings.py
| +----wsgi.py
+---+blog/
+----__init__.py
+----models.py
+----views.py
+----tests.py
+----migrations
+---__init__.py

我的项目/wsgi.py:

#!/usr/bin/python
import os
virtenv = os.environ['OPENSHIFT_PYTHON_DIR'] + '/virtenv/'
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
exec(compile(open(virtualenv, 'rb').read(), virtualenv, 'exec'), dict(__file__=virtualenv))
except IOError:
pass

from myblog.wsgi import application

我的项目/我的博客/wsgi.py:

import os
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myblog.settings")
application = get_wsgi_application()

我的Django版本是最新的1.9.2,python 3.3是openshift提供的。

感谢您关注我的问题并帮助我解决问题。

最佳答案

仅限 Django 1.9 supports Python 3.4 or higher .您的特定错误是由调用 find_spec 引起的 added in Python 3.4 .

您可以降级到 Django 1.8 或选择其他支持 Python 3.4 的 PaaS 提供商。

关于python - Openshift 上的 Django - 500 内部服务器错误 - wsgi.py 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35670079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com