On Mac OS X, if homebrew, python3, and vim are major components in your workflow then it works best if you leave the system python alone, don't install python.org Python but rather install python ( 2 and 3 ) using brew install
. Then install vim using homebrew also. If you want python3 use the flags --with-python3 --without-python
and voila, you will indeed be using the same python in vim and out of vim.
pip3 should function as expected and leave your system python alone.
The reasoning behind why I say that you would want not to install the Python.org distribution of python alongside homebrew:
Homebrew wants to use its own python. Even if you are not installing python3 for your direct usage, chances are that something you install with homebrew will need it, and thus it will be installed.
Mac OS X wants to to use it's own inbuilt python (2.7). You're better off leaving this python alone, in terms of installing extra packages.
You want pip (and pip3) to install packages for the same python as what you would get when you go to your shell. You should ideally be able to say $ pip3 install foo
at the shell and have 'foo' installed for the python you would reach at a $ python3
prompt.
And, lastly, you want vim to use that same python. If vim is installed with homebrew, your python, homebrew's python, pip's python, and vim's python are all the same, and OS X has it's own.
Now, in this scenario, the addition of Python.org's python adds a third python, greatly complicating matters.
Previously, I was accustomed to installing the Python.org pythons (2 and 3) just after a fresh install. Then, I would install Xcode so I could clone vim from source and build with dynamic python3 support against python3. Upon compiling vim, I would typically clobber the inbuilt vim7.3 of Mac OS X with my own. This was all before I had touched homebrew – I was using MacPorts prior to that. Homebrew follows a different philosophy than MacPorts, and I have found that it is much easier to go with the flow, so to speak, with homebrew and python, because the alternative is to always have to explicitly specify the full path to python whenever using pip. Instead of pip3 install foo
it becomes /Library/Frameworks/Python.framework/Versions/3.x/bin/python3 -m pip3 install foo
. It is not pretty or fun to have to worry about that.