I have recently switched to vim and configured it for Python-programming using this tutorial. Before, I have made sure that vim supports python3 (vim --version shows +python/dyn and +python3/dyn) using this article.
But when executing a file from python-mode, still the python2.7 interpreter is chosen.
How can I configure vim (or the python-mode) to run files on the python3 interpreter?
My OS is Ubuntu 14.04 x64.
Thanks in advance!
Try adding this to your .vimrc file
I found this in the help docs. In vim type:
By default, vim is not compiled with python3 support, so when I tried this, I got all kinds of errors... Which tells me it's trying to use python3. But if your
vim --version
output shows +python3 you should be good.EDIT: By default, Ubuntu 14.04 doesn't come with +python3 support. And due to limitations, you can't have both python2 and python3 support.
So, you have to compile vim with python3 support.
These are the steps that worked for me: From a linux command line:
Install packages
Grab the latest version of vim
Configure it
Compile it
Test it
Install it
Link the package
Now, you have both versions of vim
To use normal vim (python2) type
vim file.py
To use vim with python3 support type
vim-py3 file.py
If you just want the python3 version, then you only need to link it to the new vim
And if you want to switch back to the python2 version, remove the link
it removes python 2.X
The symbolic link (
/usr/bin/vim
->/etc/alternatives/vim
) is become useless, probably because the vim executable deleted from/etc/alternatives
I also met the same problem. My device is a Mac, so it may be a bit different. I use Homebrew to manage my packages.
brew install vim
will download Vim with Python.So you can download Vim with Python 3 with
brew install vim --with-python3 --HEAD
There may be some other operations. You may need something like
brew unlink vim
.I removed the The symbolic link (/usr/bin/vim) since it does not work any more and relinked the vim