0

将 sockjs 与 Tornado 一起使用。在服务器运行时,这是返回的跟踪:

python server.py 
Traceback (most recent call last):
  File "server.py", line 10, in <module>
    from sockjs.tornado import SockJSRouter
  File "/Users/mohit/anaconda/envs/py34/lib/python3.4/site-packages/sockjs/__init__.py", line 20, in <module>
    from sockjs.route import get_manager, add_endpoint
  File "/Users/mohit/anaconda/envs/py34/lib/python3.4/site-packages/sockjs/route.py", line 11, in <module>
    from sockjs.transports import handlers
  File "/Users/mohit/anaconda/envs/py34/lib/python3.4/site-packages/sockjs/transports/__init__.py", line 3, in <module>
    from .jsonp import JSONPolling
  File "/Users/mohit/anaconda/envs/py34/lib/python3.4/site-packages/sockjs/transports/jsonp.py", line 8, in <module>
    from .base import StreamingTransport
  File "/Users/mohit/anaconda/envs/py34/lib/python3.4/site-packages/sockjs/transports/base.py", line 2, in <module>
    from aiohttp import errors
ImportError: cannot import name 'errors'
4

1 回答 1

0

我建议您将 python 版本升级到 Python 3.5+ 并使用 PEP-492 aka async/await。如果您使用的是 Python 3.4,请将 await 替换为 yield from 并将 async def 替换为 @coroutine 例如:

async def coro(...): ret = await f()

应替换为:

@asyncio.coroutine def coro(...): ret = yield from f()

来自 aiohttp 文档:

依赖 项 Python 3.4.2+

chardet, multidict, async_timeout,yarl

或者,您可以安装 cChardet 和 aiodns 库(为了速度,强烈推荐)。

$ pip install cchardet

$ pip install aiodns

于 2017-03-26T09:31:15.073 回答