Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: Generator expression must be parenthesized

Tags:

python

django

I just installed django and after installing that I created a django project and was trying to run django server by command:

python manage.py runserver 

After that I'am getting error as: SyntaxError: Generator expression must be parenthesized

error screenshot

like image 754
sagar Avatar asked Jul 10 '18 12:07

sagar


People also ask

What is GenExpr?

GenExpr is the internal language used by gen patchers. It is used to describe computations in an implementation agnostic manner. To perform actual computations, it is translated into machine code for the CPU or GPU by the various Gen objects ( gen~ , jit. gen , etc.).

Why is generator used in Python?

Generators have been an important part of Python ever since they were introduced with PEP 255. Generator functions allow you to declare a function that behaves like an iterator. They allow programmers to make an iterator in a fast, easy, and clean way.

Are generators faster than lists Python?

List comprehensions are usually faster than generator expressions as generator expressions create another layer of overhead to store references for the iterator. However, the performance difference is often quite small.


2 Answers

TL; DR: Upgrade Django to version 1.11.17+ or 2.0+


This error is a known incompatibility related to Python issue #32012. Projects based on Django 1.11.16 and below will raise this exception when started with Python 3.7. A patch for this issue has been merged into Django 2.0 and 2.1 branches and cherry-picked later into Django 1.11.17.

Note: Python 3.7 is officially supported by Django 1.11.17 and above, including any 2.x branch.

like image 155
Antwane Avatar answered Sep 17 '22 18:09

Antwane


Generator expression must be parenthesized

> Update Django version to 1.11.17

pip install django==1.11.17 
like image 43
Sudhanshu Shekhar Jha Avatar answered Sep 21 '22 18:09

Sudhanshu Shekhar Jha