'How to correctly install YouCompleteMe on mac?

I have the following line in ~/.vimrc

Plugin 'valloric/youcompleteme'

Running PluginInstall successfully installed the plugin.

Then I ran python3 install.py --clang-completer under /Users/$UserName/.vim/bundle/youcompleteme.

Running vim gave me:

YouCompleteMe unavailable: requires Vim compiled with Python (3.5.1+) support.

The python3 version is 3.6.8.

vim --version shows that it has python3 support:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 13 2019 14:45:40)
Included patches: 1-503, 505-680, 682-1312
Compiled by [email protected]
Normal version without GUI.  Features included (+) or not (-):
+acl               +extra_search      -mouse_netterm     -tag_old_static
-arabic            -farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    -tcl
+autochdir         +find_in_path      -mouse_urxvt       -termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
-balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
+builtin_terms     -gettext           +netbeans_intg     +textprop
+byte_offset       -hangul_input      +num64             +timers
+channel           +iconv             +packages          +title
+cindent           +insert_expand     +path_extra        -toolbar
-clientserver      +job               -perl              +user_commands
-clipboard         +jumplist          +persistent_undo   -vartabs
+cmdline_compl     -keymap            +postscript        +vertsplit
+cmdline_hist      +lambda            +printer           +virtualedit
+cmdline_info      -langmap           -profile           +visual
+comments          +libcall           +python/dyn        +visualextra
-conceal           +linebreak         -python3           +viminfo
+cryptv            +lispindent        +quickfix          +vreplace
+cscope            +listcmds          +reltime           +wildignore
+cursorbind        +localmap          -rightleft         +wildmenu
+cursorshape       -lua               +ruby/dyn          +windows
+dialog_con        +menu              +scrollbind        +writebackup
+diff              +mksession         +signs             -X11
+digraphs          +modify_fname      +smartindent       -xfontset
-dnd               +mouse             +startuptime       -xim
-ebcdic            -mouseshape        +statusline        -xpm
-emacs_tags        -mouse_dec         -sun_workshop      -xsmp
+eval              -mouse_gpm         +syntax            -xterm_clipboard
+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa
vim


Solution 1:[1]

I use YouCompleteMe for C and built vim 8.2 from source on my mac with OSX 10.15. If you want to use it for c-family languages it's pretty finicky. You might spend a lot of time reading posts like these, ones where someone was having a different issue 3 months ago and there's no answer.

To build vim with python3 support you can do one of two things,

git clone https://github.com/vim/vim.git
cd vim
git pull
cd src 
make distclean 
./configure --with-features=huge 
make
sudo make install

This will give you more than just python3. There aren't any drawbacks to having the extra features as far as I know. my vim is installed in $HOME, I think the install script symlinked the binary to /usr/local/bin/vim.

or you can use homebrew and macvim which is what I would recommend,

brew install macvim

sources:

https://www.vim.org/git.php

https://vim.fandom.com/wiki/Building_Vim

Solution 2:[2]

YouCompleteMe need that VIM, that VIM must support Python3.

(That means that you need to use Python3 to config installling VIM).

As your VIM 's "vim --version" shows, your installed VIM Do Not Support

Python3(Beacuse the symbol before python3 is that '-', that '-' minus

means Your installed VIM do not support python3).

Even your Mac defualt python3 is over 3.5.1,

your installed VIM support python@2(from "+python/dyn" sa your "vim --version" shows).

Please use Homebrew reinstall VIM with supporting python3,

DO NOT USE your Mac default installed VIM.

Could refer:

0.Installing Vim with Python3 support on MacOS.

1.Debian Manually install VIM which suppoet Python3.

2.How do I install vim on OSX with Python 3 support?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2