4
$\begingroup$

I added a line and am very sure there is no indentation problem. Here is the error report and screenshots of the text so you can see it:

Error: File "C:\Users\info\Desktop\Claas UI.blend\Claas_UI_2.py", line 40 bpy.ops.object.mode_set( mode = 'EDIT' )

TabError: inconsistent use of tabs and spaces in indentation location: :-1

Error: Python script fail, look in the console for now...

enter image description here enter image description here

When I remove the line with the arrows and uncoment the previous lines below it all runs fine.

enter image description here

Any idea what causes this?

$\endgroup$
6
$\begingroup$

Python doesn't like inconsitently mixed tabs and spaces for indentation.

Ctrl-T opens the property panel, check that the Tabs as Spaces is ticked.

You can usually fix this by unindenting the lines in question by Shift-Tab to the first column and re-indent them Tab again.

enter image description here

Related:

$\endgroup$
  • $\begingroup$ This is rather bizarre. I use tabs from the beginning and not spaces. So I reset all tab steps and then formatted the text again. It worked. Must have by accident adjusted some text via spaces. $\endgroup$ – Claas Kuhnen Jan 6 '16 at 13:07
1
$\begingroup$

Recently I faced a similar problem. I was using the sublime editor. it's not an issue with the code but with the editor.

Below change in the preference settings worked for me.

Sublime Text menu -> Preferences -> Settings: Syntax-Specific:

{ "tab_size": 4, "translate_tabs_to_spaces": true }

$\endgroup$
0
$\begingroup$

That error was driving me crazy. To solve on Visual Studio Code. Click with mouse right button, and select Command Palette on your code, and after that select de command 'Convert Indentation to Tabs'

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.