Unable to use Vim to open LaTeX files on Mac, caused by Python?

Viewed 308

The problem:

MacVim is failing me at opening *.tex files. I have nothing too fancy for this specific filetype (vimtex and vim-latex-suite, at most), yet, I cannot use MacVim to edit *.tex files on my MacBook Air, running latest OS X.

  • If I open the *.tex file through a graphical interface (MacVim), the MacVim process simply quits;
  • If I try to call macvim from the Terminal, to open such *.tex file, I will end up with the following diagnostic info:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fff9b28c3c0 (most recent call first):
Vim: Caught deadly signal ABRT
Vim: Finished.
  • For now, I am settled with typing my LaTeX documents through the plain vim interface @ the terminal.

Failed troubleshooting attempts:

I do not have trouble using python and python3 command through the Terminal (this is a Mac, after all); and I have also tried to specify the following $PYTHONHOME to Vim. This did not help me to restore MacVim functionality with *.tex files.

let $PYTHONHOME = "/Users/llinfeng/anaconda2/bin/python"

Vim-configuration info

Also, I don't see myself doing anything fancy in the ~/.vim/ftplugin/tex.vim file. Notably, I am reusing almost all the Vim settings across Windows, Linux and Mac machines. So far, I have been happily typing LaTeX in my Windows and Linux machine.

Please let me know if there is further diagnostics info that I can provide.

1 Answers

With all credits attributed to @ryuichiro (see comments), running the following command through Terminal helped solve the problem:

brew upgrade python3

I can now type LaTeX documents as usual; but, I have no idea why python3 should be "upgraded" to get MacVim back alive. [Will add explanation if I am briefed with one.]

Related