Python/twisted 在 Windows 上导入twisted.internet.endpoints

标签 python windows twisted

我正在尝试使用 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/

相关文章:

python - 什么被传递给 scrapy DownloaderStats 中间件?

python - 扭曲连接丢失事件

python - Twisted如何读取/etc/hosts?

python - 套接字编程;通过多个设备传输时文件损坏

python - 单击一个图可在绘图中打开另一个图

windows - 为什么我必须在批处理文件的 for 循环中转义我已经转义的搜索字符串?

php - 如何从 php 将参数传递给 windows 命令行程序中的可执行文件?

windows和linux的php md5_file区别

python - 没有 init 方法接受参数的类

python - scikit-image 无法导入图像