If you are using Sublime text for python development,you can avoid the error by using the package Anaconda.After installing Anaconda,
- open your file in sublime
- right click on the open spaces
- choose anaconda
- click on autoformat
- DONE Or Press CTRL+ALT+R.