install vim-8.2 version with python2 and python3 supported on Ubuntu 18.04
you can run the command to check whether your vim is supported by python2 and python3
vim --version
if you can seek “+python2”, “+python3”, congratulations, you have already resolved the problem, and you can quit
-
use the command to remove the old vim without python2 or python3 supported
sudo apt remove vim
-
click this web and download the source code of vim-8.2
-
use the command to install the dependency of vim (such as gcc, make, python2 and python3, et.)
sudo apt install gcc make python-dev python3-dev libncurses5-dev
you can use this command to examine whether one dependency was installed well
gcc --version
if there exist some information about gcc to be printed in the terminal, gcc was installed well
-
change the directory to “vim-master/src”, which is the source code you just downloaded, and run the command
./configure --with-features=huge --enable-python3interp=yes --with-python3-config-dir=/usr/lib/python3.6 --prefix='/usr/local/vim82/'
–with-features=huge | maximum features supported |
---|---|
–enable-pythoninterp=yes | turn on the support of python2 |
–with-python-config-dir=/usr/lib/python2.7 | indicate the path of python2.7 |
-enable-python3interp=yes | turn on the support of python3 |
–with-python3-config-dir=/usr/lib/python3.6 | indicate the path of python3.6 |
–prefix=’/usr/local/vim82/’ | indicate the path of vim |
-
start Compilation
make sudo make install
-
add the vim to the PATH (or make a soft link)
sudo ln -s /usr/local/vim82/bin/vim /usr/bin
-
use these commands to check status of vim
vim --version
or
vim :python3 import sys; print(sys.version)
if you can see the version of your python3, congratulations, you are successful.