9

When installing Vim on Mac OS with +python3 support I get the following error:

% brew install vim --with-python3
Usage: brew install [options] formula

...

Error: invalid option: --with-python3
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
mattr
  • 5,458
  • 2
  • 27
  • 22

2 Answers2

12

+python3 is now enabled by default on Vim via Homebrew as of 2019. Older instructions out on the internets are not accurate (and I will not link to them to avoid raising their search ranking).

Simply install/upgrade via Homebrew:

% brew uninstall vim # optional, only if you previously installed it 
% brew install vim

Verify +python3:

% /usr/local/bin/vim --version
...
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           -python            +visual
+cmdline_info      +libcall           +python3           +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
...

Note, you still will have the system default Vim installed and it may be in your PATH before your Homebrew installed version, so if you do vim --version and it doesn't show +python3:

  1. try restarting your terminal
  2. try alias vim=/usr/local/bin/vim
  3. try adjusting your PATH variable to put Homebrew's Vim first. "editing PATH variable on mac" has additional information.
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
mattr
  • 5,458
  • 2
  • 27
  • 22
0

Just write: rm '/usr/local/bin/2to3' then, brew link --overwrite python@3.9