I have installed twisted and Autobahn websocket by using

pip install twisted
pip install autobahn

But when I import any of the factories from Autobahn, I get the cannot import name error.

    >>> from twisted.internet import reactor
    >>> from autobahn.websocket import WebSocketClientFactory
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
    ImportError: cannot import name WebSocketClientFactory

Is there anything I am missing? Here's the pip freeze

Twisted==13.2.0
Twisted-Core==12.3.0
Twisted-Names==12.3.0
Twisted-Web==12.3.0
autobahn==0.7.4
websocket==0.2.1
websocket-client==0.13.0
有帮助吗?

解决方案

It looks as thoough WebSocketClientFactory is in twisted sub-module:

from autobahn.twisted.websocket import WebSocketClientFactory

其他提示

Seems like installing python3 with pip and then installing autobahn solves this issue

Command below is for ubuntu users :

sudo apt-get install python3-pip
sudo pip3 install autobahn
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top