Python: import autobahn_autoreconnect 导致 RuntimeError

Python: import autobahn_autoreconnect causes RuntimeError

我想使用模块 autobahn-autoreconnect,它在本地与 PyCharm 配合使用效果很好。我只是用 PyCharm 安装模块并将旧的 ApplicationRunner 行换成新的:

# from autobahn.asyncio.wamp import ApplicationRunner
from autobahn_autoreconnect import ApplicationRunner

但是当我使用 pip3 install autobahn-autoreconnect 在 Ubuntu 服务器上安装它然后仅使用 import autobahn_autoreconnect 时,我收到以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/autobahn_autoreconnect/__init__.py", line 31, in <module>
    from autobahn.wamp import protocol
  File "/usr/local/lib/python3.5/dist-packages/autobahn/wamp/protocol.py", line 272, in <module>
    class ApplicationSession(BaseSession):
  File "/usr/local/lib/python3.5/dist-packages/autobahn/wamp/protocol.py", line 277, in ApplicationSession
    log = txaio.make_logger()
  File "/usr/local/lib/python3.5/dist-packages/txaio/_unframework.py", line 43, in _throw_usage_error
    "To use txaio, you must first select a framework "
RuntimeError: To use txaio, you must first select a framework with .use_twisted() or .use_asyncio()

我做错了什么?

以下解决方案对我有用。

第一个:

import txaio
txaio.use_asyncio()

第二个:

from autobahn_autoreconnect import ApplicationRunner