python - Django mod-python错误

标签 python django

谁能告诉我这个奇怪的错误是什么

 Mod_python error: "PythonHandler django.core.handlers.modpython"

 Traceback (most recent call last):

 File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 287, in HandlerDispatch
log=debug)

 File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 464, in import_module
  module = imp.load_module(mname, f, p, d)

 File "/project/django/django/core/handlers/modpython.py", line 4, in ?
  from django import http

File "/project/django/django/http/__init__.py", line 3, in ?
 from Cookie import SimpleCookie, CookieError

 ImportError: No module named Cookie


 Edit:
  Python   
 Python 2.4.3 (#1, Jan 14 2008, 18:32:40) 
 [GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> from Cookie import SimpleCookie, CookieError
  >>> from http.Cookie import SimpleCookie, CookieError
  Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  ImportError: No module named http.Cookie
 >>> import Cookie
 >>> import http.Cookie
 Traceback (most recent call last):
  File "<stdin>", line 1, in ?
 ImportError: No module named http.Cookie
 >>> import http.Cookie

最佳答案

您缺少 Cookie 包(它不是 Django 的一部分),但它应该是内置的。

如果您使用的是 Python 3,请注意 Cookie 已重命名为 http.cookies,并且 Django 与 Python 不兼容,而不是 2.x。

这就是您所缺少的:http://docs.python.org/library/cookie.html .

编辑

我看到您正在运行 python 2.4。考虑切换到 python 2.6 或 2.7,并检查是否存在 /usr/lib/python2.4/Cookie.py

解决方案

缺少路径,所以添加

sys.path.append('/usr/lib/python2.4/')

解决问题。

关于python - Django mod-python错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3522029/

相关文章:

python - 如何检查 Python 程序是否已在 Visual Studio 中启动?

python - 有没有办法撤消 Django 上的迁移并从 showmigrations 列表中取消选中它?

python - 连续分数到分数故障

python - Django/Celery - AttributeError : module 'novopagemento' has no attribute 'celery'

django - 在使用 Django 的控制台脚本中记录到 stderr

django - 在 Django 中使用 Firebase 身份验证

python - 使 Django forms.py 变干的好习惯

python - pd.Series.str.lower.replace ('str' , 'replace_str' ) 不起作用但 pd.Series.str.replace。 ('STR' , 'replace_str' ) 呢?

python - 在 pytest 中使用命令行选项进行非 python 测试

django - 如何使 Django 模型仅在 Django Admin 中查看(只读)?