How to Solve NameError: name 'with_statement' is not defined -- __future__

Solution: Import the 'with_statement' module

To Solve the error, add the following line to the top of your code.

from __future__ import with_statement

 

For more information:
Python __future__ with_statement