"inconsistent use of tabs and spaces in indentation" "inconsistent use of tabs and spaces in indentation" python python

"inconsistent use of tabs and spaces in indentation"


Don't use tabs.

  1. Set your editor to use 4 spaces for indentation.
  2. Make a search and replace to replace all tabs with 4 spaces.
  3. Make sure your editor is set to display tabs as 8 spaces.

Note: The reason for 8 spaces for tabs is so that you immediately notice when tabs have been inserted unintentionally - such as when copying and pasting from example code that uses tabs instead of spaces.


Using the autopep8 command below fixed it for me:

 autopep8 -i my_file.py

Documentation for autopep8 linked here.


For VSCode users

Ctrl+Shift+P or View->Command Palette.

Type

>Convert Indentation to Spaces

press Enter.