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.

helloB
  • 3,472
  • 10
  • 40
  • 87
  • Possible duplicate of [Make Emacs use UTF-8 with Python Interactive Mode](http://stackoverflow.com/questions/888406/make-emacs-use-utf-8-with-python-interactive-mode) – JCC Sep 08 '16 at 15:22

2 Answers2

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.

Andreas Röhler
  • 4,804
  • 14
  • 18
  • May want to include the inverse command `tabify` which does the same thing in reverse (converts multiple spaces to tabs). – JCC Sep 08 '16 at 15:16
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

iScrE4m
  • 882
  • 1
  • 12
  • 31