【发布时间】:2018-11-26 01:00:34
【问题描述】:
我正在尝试使用 Klein 运行twistd web,但遇到了很多问题。 即使尝试从示例中运行它-得到相同的结果。 Source
from klein import Klein
app = Klein()
@app.route('/')
def hello(request):
return "Hello, world!"
resource = app.resource
然后运行它(在本例中,上面的文件保存为twistdPlugin.py:
$ twistd -n web --class=twistdPlugin.resource
错误:
sh-3.2# twistd -n web --class=twistdPlugin.resource
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/twistd", line 11, in <module>
load_entry_point('Twisted==17.9.0', 'console_scripts', 'twistd')()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/twisted/scripts/twistd.py", line 29, in run
app.run(runApp, ServerOptions)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/twisted/application/app.py", line 657, in run
config.parseOptions()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/twisted/application/app.py", line 624, in parseOptions
usage.Options.parseOptions(self, options)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/twisted/python/usage.py", line 267, in parseOptions
self.subOptions.parseOptions(rest)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/twisted/python/usage.py", line 255, in parseOptions
self._dispatch[optMangled](optMangled, arg)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/twisted/python/usage.py", line 411, in <lambda>
fn = lambda name, value, m=method: m(value)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/twisted/web/tap.py", line 121, in opt_class
classObj = reflect.namedClass(className)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/twisted/python/reflect.py", line 173, in namedObject
module = namedModule('.'.join(classSplit[:-1]))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/twisted/python/reflect.py", line 159, in namedModule
topLevel = __import__(name)
ModuleNotFoundError: No module named 'twistdPlugin'
这个怎么办?
【问题讨论】:
标签: python-3.x twisted klein-mvc