I have been trying to compile Vim with python3 on my Mac for many hours, as a result, it looks fine now, as the following:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 9 2018 00:37:54) macOS version Included patches: 1-573 Huge version without GUI.
+python/dyn +python3/dyn

but when I tried to test using :echo(has('python3')), it gives 0.

And command like :python3 print('aha!') gives error:

E370: Could not load library libpython3.7m.a
E263: Sorry, this command is disabled, the Python library could not be loaded.

While python2 works fine. Can anyone help me with mercy?!

Thank you so so much!

p.s. this is my .configure used:

./configure --with-features=huge \
--enable-multibyte \
--enable-rubyinterp=yes \
--enable-python3interp=yes \
--with-python3-config-dir=/Users/mac/anaconda3/lib/python3.7/config-3.7m-darwin \
--enable-pythoninterp=yes --with-python-config-dir=/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config \
--enable-luainterp=yes \
--enable-hangulinput=yes \
--enable-cscope \

by the way, --with-python3-config-dir=/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin \ works the same.

  • Do you have specific reasons not to use the pre-compiled MacVim? It is already compiled for python3.7 and can also be used in the terminal (alias vim='mvim -v'). It can be configured to use your anaconda python3 installation: github.com/macvim-dev/macvim/wiki/… (not tested by myself) – Hotschke Dec 10 '18 at 13:02
  • What surprises me, is that at the top it looks like vim is compiled with python dynamic support (+python3/dyn), but the name libpython3.7m.a looks like a lib for static linking. Try configure option --enable-python3interp=dynamic. – Ralf Jan 22 at 10:23

Find your dynamic python lib, it is like libpython3.6m.so.1.0. Then put it in your .vimrc like this:

set pythonthreedll=/location/of/your/python/lib/
  • I think pythonthreedll should be set to dynamic python lib. Your examples looks like a directory. – Ralf Jan 22 at 10:26
  • "/location/of/your/python/lib/" is supposed to point to the location of the dynamic python lib ,not a directory. @Ralf – peter Feb 13 at 6:09

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.