Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Using Databases in Python Our Diary App Switching It Up

The Diary application shows Indentation error.

When I execute the application using ./diary.py it shows me the following error. I tried even the original script downloaded from treehouse but it still gives me the same error.

nagabhushan@nagabhushan-Inspiron-1525:~$ ./diary.py

File "./diary.py", line 13 class Meta: ^

TabError: inconsistent use of tabs and spaces in indentation

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

It is not always obvious what causes a "TabError: inconsistent use of tabs and spaces in indentation" because, depending on the display or code editor, the code may appear to be aligned, but actually has indention errors because a TAB is not always represented the with the same number of spaces everywhere.

The recommendation is to use only spaces (preferably 4-spaces!) for indenting and completely avoid TABs for this reason.

The error message tells you that the error is around line 13. Indentation errors are sometimes cause by the preceding line!

Otherwise, try searching your code for TABs and replace them with spaces. If you're able to load the code into a syntax-aware editor (emacs, vim, pycharm, sublime, etc.) or run a syntax checker such as pyflakes or pylint the error should be quickly obvious.