在第一次 HTTP GET 期间(在重新加载守护进程模式下的 WSGI 之后),admin.site.unregister 抛出一个 NotRegistered 异常,但 admin.site.register 抛出一个 AlreadyRegistered 异常(catch-22?)但是,在随后的 HTTP GET 中,一切都加载得很好,没有错误。
设置:
设置.py:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
#'django.contrib.sites', #(this didn't seem to make a difference)
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'base',
'sample',
'reports',
'south',
)
Run Code Online (Sandbox Code Playgroud)
模型.py:
from django.db import models
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行在同一VirtualHost. 其中一个应用程序是此处myapp指定的标准 hello-world 代码。它加载得非常好。另一个应用程序是 Django 网站。它失败并显示.uiappImportError
我在wsgi 文档中读到, 的值python-path附加到sys.path,所以这就是我在WSGIDaemonProcessfor中指定的值uiapp。
我无法确定问题是出在 Python 代码上还是 Apache 配置上。
这是我的虚拟主机配置:
[ . . . ]
# processGroups
WSGIProcessGroup uiapp
WSGIProcessGroup myapp
# configurations for django sites
WSGIScriptAlias /uiapp "/some/path/ui_dir/site_prod/wsgi.py"
WSGIScriptAlias /myapp "/some/other/path/myapp.wsgi"
# daemons
WSGIDaemonProcess uiapp processes=2 threads=25 display-name=site_prod_wsgi python-path=/some/path/ui_dir
WSGIDaemonProcess myapp processes=2 threads=25 display-name=helloworld_wsgi
# doc root for /uiapp
<Directory "/some/path/ui_dir/site_prod">
Order allow,deny
Allow from all
</Directory>
# …Run Code Online (Sandbox Code Playgroud) 我需要开发一个python(v2.7)wsgi应用程序来接收和解析从另一个Web发布的json对象中的数据.
示例JSON对象的格式如下所示.
{
"BuildId":"4c53575f-36f48a7f1f37",
"EventId":1,
"EventName":"Archiving Complete",
"EventDescription":"Fired each time the build products finish unzipping on an archive server after a successful build.",
"ConfigurationId":2021,
[
{
"archive_server":"CA",
"ftp":"ftp://ABC.com/2011_V2/ccoderre_build_dev_build/2011.4.103.002",
"dfs":"\\\\ABD.com\\ccoderre_build_dev_build\\2011.4.103.002"
}
],
"Changelists":
[
{
"author":"mike",
"description":"integrating from mainline\n",
"number":1233242,
"status":"OK",
"submit_time":"\/Date(1305844615000)\/"
}
],
"InheritedChangelists":[],
"CustomEventInfo":
[
{
"Key":"ArchiveServer",
"Value":"buildfsct"
},
{
"Key":"HasSymbols",
"Value":0
}
]
}
Run Code Online (Sandbox Code Playgroud)
如何使用wsgi来获取(读取)"BuildId","ConfigurationId","ftp"等?谁能帮我?提前致谢!
所以我犯了运行Ubuntu Server(12.04)的错误.我安装了Python3和mod_wsgi的python3版本.
Apache2启动 - 但保留以下错误日志:
[Mon May 05 11:00:24 2014] [error] python_init: Python version mismatch, expected '2.7.2+', found '2.7.3'.
[Mon May 05 11:00:24 2014] [error] python_init: Python executable found '/usr/bin/python'.
[Mon May 05 11:00:24 2014] [error] python_init: Python path being used '/usr/lib/python2.7/:/usr/lib/python2.7/plat-linux2:/usr/lib/python2.7/lib-tk:/usr/$
[Mon May 05 11:00:24 2014] [notice] mod_python: Creating 8 session mutexes based on 80 max processes and 0 max threads.
[Mon May 05 11:00:24 2014] [notice] mod_python: using mutex_directory /tmp
[Mon May 05 11:00:24 2014] [warn] mod_wsgi: Compiled …Run Code Online (Sandbox Code Playgroud) 我试图返回到客户端 mysql 数据,我得到 mod_wsgi (pid=2304): 异常发生处理 WSGI 脚本 TypeError: 期望的字节字符串值序列,找到类型列表的值\r
def application(environ, start_response):
result = ChildClass().getValue()
status = '200 OK'
output = result
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
print(output)
return [output]
class ChildClass(): # define child class
print('ppp')
def __init__(self):
print("Calling child constructor")
def childMethod(self):
print('Calling child method')
#Parentclass().parentMethod()
def getValue(self):
# Open database connection
db = mysql.connector.connect(user='root', password='55118',host='127.0.0.1',database='test')
cursor = db.cursor()
query = ("SELECT * from employees2")
cursor.execute(query)
#for (first_name) in cursor:
return cursor.fetchall()
Run Code Online (Sandbox Code Playgroud)
如何将 cursor.fetchall …
我正在为 Centos 7 寻找 mod_wsgi 的 python3 版本。我知道对于 Fedora,它是 python3-mod_wsgi,而 ubuntu 是 libapache2-mod-wsgi-py3。但是,我找不到 Centos 7 的等效项。我需要这个包才能运行我的 django 网站。
正如之前在多个问题/答案中强调的那样,即这个和这个我已经将我的配置WSGISocketPrefix为/etc/httpd/run/wsgi
/etc/httpd/run 目录具有 root:apache 权限,创建的 sock 文件具有 apache:root 权限。
我面临的问题是 apache总是试图连接到比它应该寻找的少一个的袜子。示例袜子是/var/run/httpd/wsgi.1769.1.1.sock但 apache 寻找/var/run/httpd/wsgi.1769.0.1.sock
AFAIK 没有权限问题,问题在于 apache 正在查找的 WSGI 袜子号。我怎样才能克服这个问题?为什么sock-versionwsgi 和 apache 之间存在不匹配?
确切的日志行: (2)No such file or directory: [client A.B.C.D:57798] mod_wsgi (pid=1549): Unable to conn
ect to WSGI daemon process 'wsgi' on '/etc/httpd/run/wsgi.1144.0.1.sock' after multiple attempts.
我已经在带有 Apache2.4.7 的 Ubuntu 服务器上安装了我的 Django 应用程序,并将其配置为在虚拟环境中使用 py3.5.2。
但是,从我在错误中看到的,它从 3.5 开始,默认为 3.4。
请解释为什么会发生这种情况:
/var/www/venv/lib/python3.5/site-packages
/usr/lib/python3.4
Run Code Online (Sandbox Code Playgroud)
请参阅下面的完整错误:
SyntaxError at /
invalid syntax (forms.py, line 2)
Request Method: GET
Request URL: http://intranet.example.com/
Django Version: 1.10.1
Exception Type: SyntaxError
Exception Value:
invalid syntax (forms.py, line 2)
Exception Location: /var/www/intranet/formater/views.py in <module>, line 7
Python Executable: /usr/bin/python3
Python Version: 3.4.3
Python Path:
['/var/www/intranet',
'/var/www/venv/lib/python3.5/site-packages',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python3/dist-packages',
'/var/www/intranet',
'/var/www/intranet/venv/lib/python3.5/site-packages']
Run Code Online (Sandbox Code Playgroud)
这是我的 apache2.conf 文件:
WSGIScriptAlias / /var/www/intranet/intranet/wsgi.py
#WSGIPythonPath /var/www/intranet/:/var/www/intranet/venv/lib/python3.5/site-packages
WSGIDaemonProcess intranet.example.com python-path=/var/www/intranet:/var/www/venv/lib/python3.5/site-packages
WSGIProcessGroup intranet.example.com …Run Code Online (Sandbox Code Playgroud) 我正在运行带有 Ubuntu 和 Apache 的服务器。现在我试图让 Anaconda 与 mod_wsgi 一起工作,但无法让它工作。
首先。如果我使用 mod_wsgi-express,它就可以工作。按照https://anaconda.org/pypi/mod_wsgi安装到 Python 部分中的说明,我可以通过首先设置PYTHONHOME=/opt/anaconda然后/opt/anaconda3/bin/mod_wsgi-express start-server.
我想使用 Apache,所以我将 mod_wsgi 模块从 anaconda 加载到 apache 中。然后我有一个看起来像这样的 VirtualHost:
WSGIPythonHome /opt/anaconda3
WSGIPythonPath /opt/anaconda3/lib/python3.6/site-packages:/path/to/application
<VirtualHost *:8080>
ServerName example.com
WSGIDaemonProcess example python-home=/opt/anaconda3 python-path=path/to/application:/opt/anaconda3/lib/python3.6/site-packages
WSGIProcessGroup example
WSGIScriptAlias / /path/to/application/wsgi.py
<Directory /path/to/application/static>
Require all granted
</Directory>
<Directory /path/to/application>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
现在到了问题。我在我的 apache 错误日志中收到此错误。如果我不PYTHONHOME=/opt/anaconda使用 mod_wsgi_express指定,我会得到同样的错误。
[Wed Mar 01 09:31:17.159233 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19356 …Run Code Online (Sandbox Code Playgroud) 我正在使用Django 1.11,Apache 2.2和mod_wsgi制作一个使用Python 2.7的Web应用程序.我在渲染页面时遇到问题.完整的追溯是,
Environment:
Request Method: GET
Request URL: http://website.com/~user/irtf/
Django Version: 1.11.1
Python Version: 2.7.13
Installed Applications:
['irtf.apps.IrtfConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mod_wsgi.server']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/path/irtf_website/mysiteenv/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/home/path/irtf_website/mysiteenv/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/home/path/irtf_website/mysiteenv/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/path/irtf_website/mysite/irtf/views.py" in index
18. return HttpResponse(template.render(request))
File "/home/path/irtf_website/mysiteenv/lib/python2.7/site-packages/django/template/backends/django.py" in render
64. context = …Run Code Online (Sandbox Code Playgroud) mod-wsgi ×10
django ×7
python ×7
apache ×5
wsgi ×3
ubuntu ×2
anaconda ×1
centos7 ×1
django-views ×1
json ×1
post ×1
python-2.7 ×1
python-3.x ×1