【发布时间】:2013-10-10 13:19:54
【问题描述】:
我正在尝试执行一个使用twisted web 的python 程序,但由于某种原因它无法导入http。我对此很陌生,我还不够熟悉来解决这个问题。我做了一些谷歌搜索,但我真的找不到任何似乎与这个特定问题相关的东西,只有一些似乎无法解决问题的模糊相似的东西。
Traceback (most recent call last):
File "./test.py", line 27, in <module>
from twisted.web import http
ImportError: cannot import name http
操作系统:CentOS 5.9 Python 版本:2.7.5
$ yum list installed | grep twisted
python-twisted-core.i386 2.5.0-4.el5 installed
python-twisted-web.i386 0.7.0-1.el5 installed
这是导入的样子:
from twisted.web import http
【问题讨论】:
-
你可以
import twisted开始吗? -
我在文件开头添加了 import twisted,它没有抱怨。我认为这意味着它可以正常导入?
-
那么
python -c "import twisted; print twisted.version"给你什么? -
python -c "import twisted; print twisted.version" Traceback(最近一次调用最后):文件“
”,第 1 行,在 中 AttributeError: 'module' object has no属性“版本” -
我怀疑你有一个非常旧的 Twisted 版本。
标签: python linux python-2.7 twisted twisted.web