2

I'm following the documentation of Django, and I've encountered a problem running this command: python manage.py shell

This is the error I get:

File "manage.py", line 7
  from django.core.management import execute_from_command_line

TabError: inconsistent use of tabs and space in indentation

I realize what it means, but I don't know how to edit my manage.py file so it works. I might have accidentally edited the indentations and now I don't know how to revert.

This is what my manage.py file currently looks like:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "polling.settings")
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)

Thanks!

2 Answers 2

4

You're using a mix of tabs and spaces as indentions in your manage.py file. Use a text editor such as SublimeText that displays the whitespaces as spaces/tabs so you can easily change them.

See http://legacy.python.org/dev/peps/pep-0008/#tabs-or-spaces for more info.

Sign up to request clarification or add additional context in comments.

3 Comments

I use notepad++ and it shows the indentations! I just don't know how I should edit them.
Convert all tabs to 4 spaces or vice versa. Don't use a mixture of both.
You can set notepad++ to convert ident with 4 spaces. Do this.
0

Look carefully through manage.py. Line 7 in particular. You are using both tabs and spaces as indentation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.