Python2 support in MacVim bottle

(Wu Yongwei) #1


Would you please re-enable the Python2 support in the MacVim bottle? It is painful enough to see the Homebrew Python suddenly changed to Python3, and it is much more painful to see ClangComplete.vim stop working.

Actually I am having to revert to the old version, though I still have problems even after doing so. I have already had non-Homebrew Python3 installed, and it is a necessity that my C++ workflow can continue to work…

Best regards,


(Inada Naoki) #2

Have you read brew info macvim?
There is --with-python@2 option.

I’m strong -1 to make it default. Default should be Python 3.

BTW, clang_complete seems supportting Python 3 already.

(Wu Yongwei) #3

Thanks for the reply.

I have just found the clang_complete update too. But there could be other scripts that depend on Python2. I have not yet done a thorough search.

It does not need to be an either-or choice. I have also checked the official MacVim binary, and found it supports both python/dyn and python3/dyn. I.e. it supports both versions dynamically.

(Inada Naoki) #4

But it has own complexity & problems. (e.g. they can’t be used at same time. Which can be used is determined by which command is used first).
And Ubuntu’s vim is built with python3interp too. (while there is vim-py2 package).

Anyway, Python 2 will be die. I think efforts for removing Python 2 is worth than efforts for supporting it.

(Wu Yongwei) #5

Thanks. I was unaware of the technical constraint. (No such restrictions existed when I used Vim on Windows.)

When trying the Python3 build of MacVim with clang_complete, I encountered a strange error:

Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named ‘encodings’

Current thread 0x00007fff8924e340 (most recent call first):
Vim: Caught deadly signal ABRT
Vim: Finished.

I found the solution via Google, and these lines in .vimrc solved it:

if has('python3')
  set pythonthreehome=/usr/local/Frameworks/Python.framework/Versions/3.6

Do you know whether there is a better solution (like some tweaks to the MacVim formula)?

(Inada Naoki) #6

I use macvim bottle and I don’t need such hack.
I tried to mvim -u NONE -U NONE to skip all my local configuration, but
:python3 print("hello") works without any problem.

(Inada Naoki) #7

Maybe, you have some dirty environment variable?

(Wu Yongwei) #8

I do not know whether I have problems in my environment. After env -i PATH=$PATH mvim -u NONE -U NONE, I still could not execute any Python scripts. Apparently other people have encountered this issue:

Anyway, a workaround exists. Thanks for your reply!

(Inada Naoki) #9

I don’t know how it can happen without explicitly breaking environment.
But did you try brew upgrade, to synchronize python and vim build?

cd /usr/local/opt/macvim/
$ otool -L Vim | grep Python
	/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/Python (compatibility version 3.6.0, current version 3.6.0)

(Wu Yongwei) #10

Python and MacVim were freshly upgraded (and they worked after I set pythonthreehome. The output of the otool command line is exactly the same as yours…

People mentioned installing MacVim from HEAD could solve the problem too, but that would require Xcode. Let us see whether the next version of MacVim could fix the problem automatically.