2017-03-25 203 views
0

与Tornado一起使用sockjs。在服务器上运行,这是返回的跟踪:ImportError:无法导入名称'错误'

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' 
+0

你能尝试在requirements.txt文件固定版本'sockjs,龙卷风== 1.0.3'? – hurturk

+0

@zatta:我安装了v1.0.3,同样的错误。 – moaglee

+0

@McGrady:我没有安装asyncio。 – moaglee

回答

0

我会建议你Python版本升级到 的Python 3.5+和利用PEP-492异步又名/ AWAIT。如果您在使用Python 3.4,请更换与产量和等待异步DEF与@coroutine例如:

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

从aiohttp文件建立:

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

应代之以

依赖关系 Python 3.4.2+

chardetmultidictasync_timeoutyarl

可选您可以安装cChardet和aiodns库(强烈推荐给速度的缘故)。

$ pip install cchardet

$ pip install aiodns

相关问题