0

I just pulled from a git repo where the users are on Python 2. My system is running Python 3 and with no changes in the code, I am getting this error:

TabError: inconsistent use of tabs and spaces in indentation

It appears that the solution is to change the char set encoding of the .py files, but working in emacs, I'm not clear how to do this. I'm seeing these instructions:

https://www.emacswiki.org/emacs/ChangingEncodings

but I don't understand how to apply these for utf-8. I'd appreciate any suggestions.

1

2 Answers 2

1

Exists a command untabify:

Convert all tabs in region to multiple spaces, preserving columns. If called interactively with prefix ARG, convert for the entire buffer.

I.e. call it with C-u to convert all TABs in buffer.

As comment points out correctly: tabify does the inverse, converts multiple spaces to tabs - while using spaces seems a common convention not just in Python.

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

1 Comment

May want to include the inverse command tabify which does the same thing in reverse (converts multiple spaces to tabs).
0

This is not a python 2/3 issue, it looks like something in that git repo has wrong indentation. The easiest fix would be to replace all tab characters in all the files with spaces using something like sed

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.