Twisted中的twistd无法在窗口中运行

4 投票
1 回答
2399 浏览
提问于 2025-04-16 02:35

在命令提示符里,我输入了 >>twistd echobot.tac

Traceback (most recent call last):
  File "C:\Python26\Scripts\twistd.py", line 18, in ?
  from twisted.scripts.twistd import run
ImportError: No module named twisted.scripts.twistd

twistd 的位置在 C:\Python26\Scripts\twistd.py

#!c:\python26\python.exe

# Copyright (c) 2001-2009 Twisted Matrix Laboratories.
# See LICENSE for details.


### Twisted Preamble
# This makes sure that users don't have to set up their environment
# specially in order to run these programs from bin/.
import sys, os, string
if string.find(os.path.abspath(sys.argv[0]), os.sep+'Twisted') != -1:
    sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),os.pardir, os.pardir)))
if hasattr(os, "getuid") and os.getuid() != 0:
    sys.path.insert(0, os.path.abspath(os.getcwd()))
### end of preamble


from twisted.scripts.twistd import run
run()

当我输入这个

from twisted.scripts.twistd import run

在 Python 中,它可以运行

1 个回答

2

试着在命令行中设置路径,像这样:

set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib   

然后再运行 twistd。

撰写回答