I have small problem with python console in QGIS. Normally, I write some code in text editior and then copy whole code to python console. Unfortunately, the console underlines the indentations with blue lines and I got en error: "unindent does not match any outer indentation level."

To solve it I need to copy paste tabs from lines where it is ok.

My question is: why is this problem occuring and how to solve in easier way? I need to say that copying tabs is unnecessary waste of time.

I am attaching the picture to illustrate the problem.

enter image description here

  • 1
    what editor do you use? There seems to be a problem with a mix of tabs and spaces as indentations... – Andreas Müller Aug 22 '16 at 8:26
  • I am using Notepad ++ – sweet.sugar.cola Aug 22 '16 at 8:34
  • 1
    you may try this: force notepad++ to use spaces instead of tabs. in notepad++ go to Settings, Tab Settings and click the option "Replace by space". For existing files with tabs, use search and replace to vonvert tabs into spaces (normally four spaces are used for one indentation level) – Andreas Müller Aug 22 '16 at 8:38
  • When I do it I notice that python console have problems exactly in this places where there are spaces instead of tabs. Anyway, if I am trying to remove spaces and put tab as a indentation in notepad++ it is still creating four spaces. – sweet.sugar.cola Aug 22 '16 at 8:43
  • what did you get, if you turn on View->ShowSymbol->ShowAllCharacters in notepad++? May be some characters are weired? By the way: i am trying to reproduce your problem with no success... Strange thing. May be someone else has an idea for you. – Andreas Müller Aug 22 '16 at 9:14

Thanks to comments I answered my question.

I had spaces mixed with tabs, which is probably something which python does not like. I changed all the tabs into spaces and turn on 'replace by space' in tab settings. Now everything works fine, even if I add new lines and change code.

| improve this answer | |

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.