0

I am trying to work with Django Channels. Every time I try to run manage.py, I get the following error:

  File "/usr/local/lib/python2.7/dist-packages/daphne/server.py", line 192
    async def handle_reply(self, protocol, message):
            ^
SyntaxError: invalid syntax

I have installed all the necessary components for Channels to work.

Sharath Sriram
  • 160
  • 2
  • 5
  • 1
    remove async at the start of the line – Denis Feb 17 '18 at 06:39
  • https://github.com/django/daphne/issues/155 please check daphne version – Anup Yadav Feb 17 '18 at 07:11
  • It's advisable at least pass crash course for the language and learn at least BASIC syntax to avoid questions like above. – Denis Feb 17 '18 at 07:15
  • @Denis `async def` is perfectly valid syntax - on Python 3.5+, which is required for Channels. Please learn the basics of the language yourself before criticising. – Daniel Roseman Feb 17 '18 at 09:11
  • @DanielRoseman File "/usr/local/lib/python2.7/dist-packages/daphne/server.py" Thank you, opinion of ADHD people is very important for us. – Denis Feb 17 '18 at 10:51
  • @Denis I have no idea what any of that comment means. Why did you show the path to the file? It's in the question, and it's part of Daphne so I have no idea why you think it is invalid syntax or why OP should edit it. – Daniel Roseman Feb 17 '18 at 11:02
  • @DanielRoseman "/usr/local/lib/python2.7/dist-packages/daphne/server.py" -> python2.7. Case is closed. – Denis Feb 17 '18 at 11:04
  • 1
    @Denis what case? What on earth are you talking about? Yes, OP is using a version of Python that is incompatible with Channels 2. What does that have to do with your initial rude comment about OP learning basic syntax? – Daniel Roseman Feb 17 '18 at 11:08
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/165325/discussion-between-denis-and-daniel-roseman). – Denis Feb 17 '18 at 11:12

1 Answers1

0

It seems You are using django channels 2.0.2, which requires python version >= 3.5:

http://channels.readthedocs.io/en/latest/one-to-two.html

I recommend to use python 3 virtualenv:

  1. Check Your python version by running python3 command, for sure.
  2. Create python3 virtualenv: virtualenv -p python3 envname
  3. Instal necessary packages (channels, etc..).
  4. If You have trouble installing channels, python3-dev package is probably missing.
Peter Svac
  • 302
  • 4
  • 4