20

I'm trying to use neovim with deoplete and UtilSnips. Both requires Python support from nvim.

I followed the instructions in :help nvim_python to set the support but the output of :echo has('python') or :echo has('python3') are both 0.

On nvim-startup I get the message UltiSnips requires py >= 2.7 or py3 and for deoplete It requires Neovim with Python 3 support ("+python3").

My python (2.7.10) and python3 (3.4.3) are both installed with homebrew. The neovim module is installed over pip and pip3 with install neovim but nvim can't find it, even when I set the let g:python_host_prog path in nvimrc.

I don't know what I am able to do anymore, has anyone an idea whats wrong with it?

Lafexlos
  • 7,618
  • 5
  • 38
  • 53
hueby
  • 331
  • 1
  • 2
  • 5
  • I'm not sure if this works. Type 'where python' or 'which python' to check if your python is properly installed. Then manually configure your nvim to look at the resultant path. Another potential problem is your nvim installation is not what you think you have installed. Did you do manual unpacking before pip install? – Patrick the Cat Aug 09 '15 at 08:53
  • My pythons are both located in /usr/local/bin/ as the output of 'which' says. I installed nvim through homebrew as they describe it in the neovim documentation for OS X. – hueby Aug 09 '15 at 10:06
  • Having this exact issue, any help appreciated – Simon Smith Aug 26 '15 at 13:45
  • Since this isn't mentioned so far: if you encounter problems with the Python support, try https://github.com/neovim/neovim/wiki/Troubleshooting#python-support-isnt-working to find out which Pythons are checked by Neovim. This is more reliable than using `:!which python` or similar. – fwalch Sep 18 '15 at 12:41

7 Answers7

15

Please follow the instruction on https://neovim.io/doc/user/provider.html#provider-python to setup the python interpreter for neovim.

First, install pynvim (previously, it was named neovim, but that has been changed) plugin

pip3 install pynvim

Print g:loaded_python3_provider

echo g:loaded_python3_provider
" for python 2.x use the following
" echo g:loaded_python_provider

If it returns 1, the python is not setup for neovim. In your ~/.config/nvim/init.vim file, set the python interpreter

let g:python3_host_prog='/path/to/python3'
" for python2, use the following instead
"let g:python_host_prog = '/path/to/python2.7'
jdhao
  • 24,001
  • 18
  • 134
  • 273
VforVitamin
  • 946
  • 10
  • 12
7

I encountered the same problem lately. Here are the steps adapted from answer of @VforVitamin where I made it working.

Assuming python2 and python3 are installed.

  1. Install neovim plugin pip3 install neovim.
  2. Open neovim.
  3. Execute command :UpdateRemotePlugins.
  4. Restart neovim.
Alex Ho
  • 139
  • 1
  • 2
1

I had the issue myself because I used neovim inside virtualenv. If so, make sure to pip install neovim inside your virtualenv, and make sure that import neovim works in the python interpreter.

If that doesn't help, you can try and run neovim with debug messages (neovim -V3, or any other logging level) and see what you can pick from there.

Beka
  • 725
  • 6
  • 22
1

I bet you have a line in your init file that starts with "set runtimepath=". Change it to "set runtimepath+="

rstnd
  • 11
  • 1
0

If when you try let [interp, errors] = provider#pythonx#Detect(2)

From the docs at https://github.com/neovim/neovim/wiki/Troubleshooting#python-support-isnt-working

You get errors, could be that you have your VIM environment variable pointed to the wrong (probably vim74) runtime directory.

Neovim needs pythonx.vim from the runtime/autoload/providers/ folder to load a python interp. Vim74 doesn't provide this file.

If you have an env. variable of VIM (with a path), it will use that as your location of your runtime files - I had my set to /usr/share/vim/vim74, changing it to the location of neovim worked. I guess there is a compile time option to point to the correct location too.

0

I was with the same problem and the solution actually cames from the question.

What I did was:

pip install --upgrade pip
pip3 install --upgrade pip

sudo pip install setuptools
sudo pip3 install setuptools

sudo pip install neovim
sudo pip3 install neovim

After it, enter in neovim and :UpdateRemotePlugins. Close it and open again.

After these steps I had neovim working properly.

Edit:

For those using Arch Linux, we have a peculiarity about Python. The steps are:

  1. Install pip (python3) and pip2 (python2): pacman -S python-pip python2-pip
  2. Instead of pip3, you should use pip2

Beyond this minor difference, the rest of commands work pretty much the same way.

Eric Douglas
  • 449
  • 7
  • 12
0

As pointed out by @fwalch, the documentation has changed to https://neovim.io/doc/user/provider.html#provider-python.

Neovim comes shipped with Python3 enabled, but you need to install the pynvim module in order to use Neovim Python3 plugins:

python3 -m pip install --user --upgrade pynvim
gigalul
  • 416
  • 3
  • 13