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.

  • 1
    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
    Commented Dec 10, 2018 at 13:02
  • 2
    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
    Commented Jan 22, 2019 at 10:23

2 Answers 2


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

set pythonthreedll=/location/of/your/python/lib/libpython3.6m.so.1.0

Of course, change the version of the library name accordingly.

  • 1
    I think pythonthreedll should be set to dynamic python lib. Your examples looks like a directory.
    – Ralf
    Commented Jan 22, 2019 at 10:26
  • 1
    "/location/of/your/python/lib/" is supposed to point to the location of the dynamic python lib ,not a directory. @Ralf
    – peter
    Commented Feb 13, 2019 at 6:09
  • 1
    set pythonthreedll=/full/path/of/python/lib/libpython3.6m.so.1.0 solves the issue Commented May 30, 2020 at 18:17

You can use the file with extension .dylib too, In my case, I set the path to use Xcode location.

set pythonthreedll=/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/Current/lib/libpython3.7m.dylib
  • 2
    Welcome to Vi and Vim! Can you add any further explanation?
    – D. Ben Knoble
    Commented Jul 24, 2020 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.