Vim is a powerful text editor, which can be scaled up to a fully-fledged IDE, especially for Python. Though, if you are reading this blog post, I guess that you already know what Vim is and I do not have to tell you about it. What I want to share though, is how to build Vim with Python 3 on macOS, when using Anaconda Python 3. If you want to use some nice plugins of Vim for Python (e.g. Pymode), then your Vim should have only Python 3 enabled. That is, you should have:
There are some solutions out there with MacVim, proposing different tricks to enable Python 3 of MacVim when Vim starts. I haven’t tried any of those, but I doubt of their functionality. So, if you agree with me up to here, then you also have tried to build Vim on your macOS. And, I guess, when you are trying to check if your Vim has properly functioning support of Python 3, by (e.g.) doing
:py3 pass, then you get the super informative error:
Vim: Caught deadly signal ABRT Vim: Finished Abort trap: 6
I struggled with this almost a week, and even at the GitHub of Vim cannot provide the solution. But, I finally found the solution and I want to share it, so other people will be helped.
I will not go into the details of the flags that one can use when configuring the building process of Vim. You can check what flags are there by using the
--help argument of the configure script. I will use some simple flags and describe the process, so you can have a fully Python 3 built Vin on your macOS.
So, let’s go!
- Download the latest stable version of Vim. You can find that by either checking the GitHub repo of Vim or going to the download page of Vim. At the moment of this blog post, the latest stable version of Vim is 8.2. Download and expand the code of the latest stable version of Vim, and then open your terminal and navigate inside of the directory of the code of Vim. I will refer to this directory as
vimrootfor the rest of this text.
- On your terminal and in the
vimrootdirectory. First issue the command:
$ export CPPFLAGS=-I/Users/< your home directory >/opt/anacoda3/include/python3.7mThen, configure your Vim building process by, e.g., using:
$ ./configure --enable-python3interp=yes \
--prefix=< vim installation path > \
--with-vim-name=< optional, name/name prefix for vim binaries >
prefix, you can use the
namefor Vim, you can use the version, for example at the moment of writing this, I use the
Then, hit enter and wait a bit.
- After the configuration is over, then is the tricky part. Now you have to make available to the building process, the shared libraries for Python. The Vim building process, tries to find those at
/usr/local/lib. To make them available, you have to issue the command:
$ sudo ln -s ~/opt/anaconda3/lib/libpython3.7m.a /usr/local/lib/and
$ sudo ln -s ~/opt/anaconda3/lib/libpython3.7m.dylib /usr/local/lib/
- Then, you can issue
$ makefollowed by
$ sudo make install
You can validate that your building is correct by opening your newly built vim with
$ vim --clean
and then issuing
in Vim. Hopefully, all will be OK!
Enjoy your Vim with anaconda Python 3, on macOS!