我正在尝试使用 python 上的twisted 编写一个服务器。 这是我的文件的头部:
from twisted.internet.protocol import Factory, Protocol
from twisted.internet.endpoints import TCP4ServerEndpoint
from twisted.internet import reactor
第一次和最后一次导入工作完美。尝试使用以下回溯运行第二次导入时出现错误:
Traceback (most recent call last):
File "<ipython-input-1-c0d6286e105b>", line 1, in <module>
from twisted.internet.endpoints import TCP4ServerEndpoint
File "C:\Anaconda3\lib\site-packages\twisted-15.5.0-py3.4.egg\twisted\internet\endpoints.py", line 34, in <module>
from twisted.internet.stdio import StandardIO, PipeAddress
File "C:\Anaconda3\lib\site-packages\twisted-15.5.0-py3.4.egg\twisted\internet\stdio.py", line 30, in <module>
from twisted.internet import _win32stdio
ImportError: cannot import name '_win32stdio'
我已经尝试过手动(使用 whl 文件)和 pip install 安装 pypiwin32 等解决方案。但问题并没有解决。
我正在使用 python 3.4.3 和 Twisted 15.0 在 Windows 7 上工作(是的!)
感谢您的帮助。
最佳答案
您正在使用 Python 3,并且 _win32stdio
未移植到 Python 3。如果您想要完整的 Twisted 功能集,您现在必须运行 Python 2(推荐使用 PyPy 4.x+) .
关于Python/twisted 在 Windows 上导入twisted.internet.endpoints,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34299034/