I'm using Anaconda and have an environment for Python27 and in the near future, one for Python3.
I ran into trouble with vim using rope, b/c my original build was linked to my /usr/local/vim ( i think..or something close to that).
I realized from reading, that i should re-build vim with:
./configure --enable-pythoninterp --with-python-config-dir=/home/wbg/anaconda/envs/py27/lib/python2.7/config --enable-prefix=/home/wbg
So I'm wondering, if there's a better way to install vim, so that when I change Anaconda environments, my vim will change too.
TIA !
Vim can be built in four ways:
- No Python support (-python, -python3)
- Python 2 support only (+python or +python/dyn, -python3)
- Python 3 support only (-python, +python3 or +python3/dyn)
- Python 2 and 3 support (+python/dyn, +python3/dyn)
I think you should opt for the last option; but, this choice brings some extra headaches. When Python 2 and Python 3 are both supported they must be loaded dynamically. And, you will not be able to use Python 2 or 3 in the same Vim session. You can build with both, but once one version of python is invoked in Vim the other cannot.
On windows, you'll want to enable dynamic loading of the python interpreter. If python is found in the path, it will be useable in vim. This frees you up from worrying where python is installed. For example:
./configure --with-features=huge --enable-pythoninterp=dynamic --enable-python3interp=dynamic
On Debian-based systems, to build both versions of python you'll need to use something like:
./configure --enable-pythoninterp=dynamic --with-python-config-dir=$(shell python-config --configdir) -enable-python3interp=dynamic --with-python3-config-dir=$(shell python3-config --configdir)
(For extra details see: https://askubuntu.com/questions/585237/whats-the-easiest-way-to-get-vim-with-python-3-support).
This is an old question, but I find this very useful, so I share it here.
conda forged vim takes care of conda envs and python linking:
conda install -c conda-forge vim
For more information: https://anaconda.org/conda-forge/vim
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With