2017-03-25 243 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

相關問題