0

Using sockjs with Tornado. On server run, this is the trace returned :

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'
vivekanon
  • 1,813
  • 3
  • 22
  • 44
  • Could you try fixing the version as `sockjs-tornado==1.0.3` in your requirements.txt file? – hurturk Mar 25 '17 at 05:32
  • @zatta : I installed v1.0.3, same error. – vivekanon Mar 26 '17 at 08:52
  • @McGrady : I don't have asyncio installed. – vivekanon Mar 26 '17 at 08:52
  • Is there a chance you are using https://github.com/aio-libs/sockjs project? I think you have a collision as sockjs is hard copied in the directory, you will need to delete the directory or install aiohttp by `pip install aiohttp` as requirement is visible in `setup.py` – hurturk Mar 26 '17 at 14:03

1 Answers1

0

I would recommend you to upgrade python version to Python 3.5+ and utilize PEP-492 aka async/await. If you are using Python 3.4 please replace await with yield from and async def with @coroutine e.g.:

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

should be replaced by:

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

from aiohttp documentaion:

Dependencies Python 3.4.2+

chardet, multidict, async_timeout, yarl

Optionally you may install the cChardet and aiodns libraries (highly recommended for sake of speed).

$ pip install cchardet

$ pip install aiodns

nivhanin
  • 1,688
  • 3
  • 19
  • 31