共享主机中的 python MemoryError
我试图在不是 django 特定的共享网络主机上部署 django。主机提供了旧版本的 python 安装,但由于我有 ssh 访问能力,我已经设法通过在我的主文件夹中本地安装它们来使用我需要的模块(包括 django)来扩展 python 安装。 好的,所以我创建了 django 项目,做了需要做的调整(设置 PYTHONPATH 和 PATH 全局变量等),制作了 django.fcgi 脚本,该脚本启动 django 并从 shell 执行 ./django.fcgi 。 这是回应:
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Traceback (most recent call last):
File "/home/tentacle/lib/python2.4/site-packages/flup-1.0.3.dev_20110405-py2.4.egg/flup/server/fcgi_base.py", line 574, in run
protocolStatus, appStatus = self.server.handler(self)
File "/home/tentacle/lib/python2.4/site-packages/flup-1.0.3.dev_20110405-py2.4.egg/flup/server/fcgi_base.py", line 1159, in handler
result = self.application(environ, start_response)
File "/home/tentacle/lib/python2.4/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/home/tentacle/lib/python2.4/site-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/home/tentacle/lib/python2.4/site-packages/django/core/handlers/base.py", line 202, in handle_uncaught_exception
from django.views import debug
File "/home/tentacle/lib/python2.4/site-packages/django/views/debug.py", line 9, in <module>
from django.template import (Template, Context, TemplateDoesNotExist,
File "/home/tentacle/lib/python2.4/site-packages/django/template/__init__.py", line 53, in <module>
from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
MemoryError
Status: 500 Internal Server Error
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>Unhandled Exception</title>
</head><body>
<h1>Unhandled Exception</h1>
<p>An unhandled exception was thrown by the application.</p>
</body></html>
所以,我知道这个问题与我的用户的内存有限有关(错误?),但是内存是否太低以至于我无法运行裸露的 django? 更糟糕的是,一个月前,同一个提供商给了我一个测试帐户,并且不仅能够运行 django,还能够在本地安装较新版本的 python 并运行良好。 我确实向我的网络主机支持人员寻求帮助,但没有得到任何可用的答案。另外,由于他们是经销商,我不太确定他们能提供多少帮助。
有办法解决这个问题吗?欢迎任何建议。
提前致谢
----------------------------------更新------------------------ ---------------------------------------
#!/home/<username>/bin/python
import os, sys
sys.path.insert(0, "/home/<username>/djangoprojects")
sys.path.insert(0, "/home/<username>/djangoprojects/testproject")
os.environ['PATH']= "/home/<username>/bin:"+os.environ['PATH']
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
这就是我的配置。我必须承认有一点错误(解释器路径),但“设置”文件路径很好。
将解释器路径更正为正确的路径后,首先我得到了 StringError (djangos 文件之一中的某些三引号文档字符串未关闭 - 嗯,几乎没有),而不是下一次运行 MemoryError ,还有MemoryError等等。一段时间(一个小时)后,我尝试再次执行脚本(没有进行进一步的更改),并不断以分段错误(核心转储)结束。
有什么建议吗?
I was trying to deploy django on a shared webhost which is not django specific. Host offers old version of python installed, but since I have ssh access ability, I've managed to extend python installation with modules I need (including django) by installing them locally in my home folder.
Ok, so I've created django project, did tweaks that needed to do (setting up PYTHONPATH and PATH globals etc.), made django.fcgi script which starts django and did ./django.fcgi from shell.
This is the response:
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
Traceback (most recent call last):
File "/home/tentacle/lib/python2.4/site-packages/flup-1.0.3.dev_20110405-py2.4.egg/flup/server/fcgi_base.py", line 574, in run
protocolStatus, appStatus = self.server.handler(self)
File "/home/tentacle/lib/python2.4/site-packages/flup-1.0.3.dev_20110405-py2.4.egg/flup/server/fcgi_base.py", line 1159, in handler
result = self.application(environ, start_response)
File "/home/tentacle/lib/python2.4/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/home/tentacle/lib/python2.4/site-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/home/tentacle/lib/python2.4/site-packages/django/core/handlers/base.py", line 202, in handle_uncaught_exception
from django.views import debug
File "/home/tentacle/lib/python2.4/site-packages/django/views/debug.py", line 9, in <module>
from django.template import (Template, Context, TemplateDoesNotExist,
File "/home/tentacle/lib/python2.4/site-packages/django/template/__init__.py", line 53, in <module>
from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END,
MemoryError
Status: 500 Internal Server Error
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>Unhandled Exception</title>
</head><body>
<h1>Unhandled Exception</h1>
<p>An unhandled exception was thrown by the application.</p>
</body></html>
So, I'm aware that this issue is about limited memory for my user (wrong?), but is it so low that I cannot run bare django?
Just for things to be worse, a month ago the same provider gave me a test account, and a was able not just to run django, but to install locally newer version of python and run it nice.
I did asked my web host support for help, but I didn't got any usable answer. Also since they are resellers I'm not very sure how much they help.
Is there a way to overcome this problem? Any suggestion is welcome.
Thanks in advance
-----------------------------------Update--------------------------------------------------
#!/home/<username>/bin/python
import os, sys
sys.path.insert(0, "/home/<username>/djangoprojects")
sys.path.insert(0, "/home/<username>/djangoprojects/testproject")
os.environ['PATH']= "/home/<username>/bin:"+os.environ['PATH']
os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
This is how look like my configuration. I must admit that there was a little error (interpreter path), but 'settings' file path was good.
After correcting the interpreter path to right one, First I've got StringError (some triple quoted doc string in one of djangos files was not closed - hm, hardly), than in next run MemoryError, and again MemoryError and so on. After a while (an hour) I tried to execute script again (no further changes made) and constantly ending up with Segmentation fault (core dumped).
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从命令行运行它时,您需要显式指定 Django 参数。假设您从
settings.py
所在的同一文件夹运行脚本:另外,检查您的
.htaccess
文件是否仍然具有正确的RewriteRule 到您的
.fcgi
脚本。When running it from the command line, you need to specify the Django parameters explicitly. Assuming you are running the script from the same folder as your
settings.py
is in:Also, check if your
.htaccess
file still has a correctRewriteRule
to your.fcgi
script.