36
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Neovim の CheckHealth において Python 連携まわりで警告が出るときの対処

Last updated at Posted at 2017-06-02

背景

Neovim を homebrew でインストールすると、 :CheckHealth コマンドを実行せよと指示が表示された。指示に従ってコマンドを実行してみると、いくつかの WARNING と ERROR が表示される。その中に Python 2 provider と Python 3 provider についてのものがあった。これを直したい。

## Python 2 provider
  - WARNING: No Python interpreter was found with the neovim module.  Using the first available for diagnostics.
  - WARNING: provider/pythonx: Could not load Python 2:
    /usr/local/bin/python2 does not have the neovim module installed. See provider-python.
    /usr/local/bin/python2.7 does not have the neovim module installed. See provider-python.
    /usr/bin/python2.6 does not have the neovim module installed. See provider-python.
    /usr/local/bin/python does not have the neovim module installed. See provider-python.
  - INFO: `g:python_host_prog` is not set.  Searching for python2 in the environment.
  - SUCCESS: pyenv found: "/usr/local/Cellar/pyenv/1.0.10_1/libexec/pyenv"
  - ERROR: Command error (1) "/usr/local/Cellar/pyenv/1.0.10_1/libexec/pyenv" which python2 2>/dev/null:
  - WARNING: pyenv couldn't find python2.
  - WARNING: pyenv is not set up optimally.
    - SUGGESTIONS:
      - Suggestion: Create a virtualenv specifically for Neovim using pyenv and use "g:python_host_prog".  This will avoid the need to install Neovim's Pytho
      n client in each version/virtualenv.
  - INFO: Executable: /usr/local/bin/python2
  - ERROR: Command error (4) /usr/local/bin/python2 -c import neovim; print(neovim.__file__): Traceback (most recent call last):  File "<string>", line 1, in
   <module>ImportError: No module named neovim
  - INFO: Python2 version: 2.7.13
  - INFO: python2-neovim version: unable to find nvim executable
  - ERROR: Neovim Python client is not installed.
    - SUGGESTIONS:
      - Error found was: unable to find nvim executable
      - Use the command `$ pip2 install neovim`
  - WARNING: Latest python2-neovim is NOT installed: 0.1.13

## Python 3 provider
  - WARNING: No Python interpreter was found with the neovim module.  Using the first available for diagnostics.
  - WARNING: provider/pythonx: Could not load Python 3:
    /usr/local/bin/python3 does not have the neovim module installed. See provider-python.
    python3.5 not found in search path or not executable.
    python3.4 not found in search path or not executable.
    python3.3 not found in search path or not executable.
    /usr/local/bin/python is Python 2.7 and cannot provide Python 3.
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - SUCCESS: pyenv found: "/usr/local/Cellar/pyenv/1.0.10_1/libexec/pyenv"
  - ERROR: Command error (5) "/usr/local/Cellar/pyenv/1.0.10_1/libexec/pyenv" which python3 2>/dev/null:
  - WARNING: pyenv couldn't find python3.
  - WARNING: pyenv is not set up optimally.
    - SUGGESTIONS:
      - Suggestion: Create a virtualenv specifically for Neovim using pyenv and use "g:python3_host_prog".  This will avoid the need to install Neovim's Pyth
      on client in each version/virtualenv.
  - INFO: Executable: /usr/local/bin/python3
  - ERROR: Command error (8) /usr/local/bin/python3 -c import neovim; print(neovim.__file__): Traceback (most recent call last):  File "<string>", line 1, in
   <module>ModuleNotFoundError: No module named 'neovim'
  - INFO: Python3 version: 3.6.1
  - INFO: python3-neovim version: unable to find nvim executable
  - ERROR: Neovim Python client is not installed.
    - SUGGESTIONS:
      - Error found was: unable to find nvim executable
      - Use the command `$ pip3 install neovim`
  - WARNING: Latest python3-neovim is NOT installed: 0.1.13

ローカル環境

pyenv と pyenv-virtualenv も homebrew でインストールしており、 shell の設定(eval "$(pyenv init -)" とか)は既に行われている状態だった。しかし system 以外の環境はインストールされていない。上記エラーで pyenv はあるけど python3 がないとかなんとか指摘されているとおり。

対処

pyenv と pyenv-virtualenv を使っているので、インストールされていない場合はそれを先にインストールする。

python2 と python3 を pyenv にインストール

pyenv install --list で調べた中でそれぞれの最新バージョンをインストールした。

pyenv install 2.7.13
pyenv install 3.6.1

Neovim 専用の virtualenv を作り、 neovim をインストール

neovim-2 という virtualenv を作って、有効化し、 neovim パッケージをインストールした。

pyenv virtualenv 2.7.13 neovim-2 # 2.7.13 を使った neovim-2 という virtualenv を作成
pyenv shell neovim-2             # 一時的に neovim-2 を有効化
pip install neovim               # neovim-2 に neovim パッケージをインストール

同様に neovim-3 も作った

pyenv virtualenv 3.6.1 neovim-3
pyenv shell neovim-3
pip install neovim

init.vim でパスを指定

エラーメッセージにあるように g:python_host_progg:python3_host_prog を以下のように指定した。(PYENV_ROOT=~/.pyenv になっている前提)

init.vim
let g:python_host_prog=$PYENV_ROOT.'/versions/neovim-2/bin/python'
let g:python3_host_prog=$PYENV_ROOT.'/versions/neovim-3/bin/python'

再起動して :CheckHealth を確認

ここで NeoVim を再起動して再び :CheckHealth してみたところ、 WARNING と ERROR が消えた。

...はずだったんだけど、今もう一度やったら WARNING が出ていた :sweat_smile: 。でも ERROR じゃないから一旦無視することにする

## Python 2 provider
  - INFO: Using: g:python_host_prog = "/Users/yuku/.pyenv/versions/neovim-2/bin/python"
  - WARNING: Your virtualenv is not set up optimally.
    - SUGGESTIONS:
      - Suggestion: Create a virtualenv specifically for Neovim and use "g:python_host_prog".  This will avoid the need to install Neovim's Python client in each virtualenv.
  - INFO: Executable: /Users/yuku/.pyenv/versions/neovim-2/bin/python
  - INFO: Python2 version: 2.7.13
  - INFO: python-neovim version: 0.1.13
  - SUCCESS: Latest python-neovim is installed: 0.1.13

## Python 3 provider
  - INFO: Using: g:python3_host_prog = "/Users/yuku/.pyenv/versions/neovim-3/bin/python"
  - WARNING: Your virtualenv is not set up optimally.
    - SUGGESTIONS:
      - Suggestion: Create a virtualenv specifically for Neovim and use "g:python3_host_prog".  This will avoid the need to install Neovim's Python client in each virtualenv.
  - INFO: Executable: /Users/yuku/.pyenv/versions/neovim-3/bin/python
  - INFO: Python3 version: 3.6.1
  - INFO: python-neovim version: 0.1.13
  - SUCCESS: Latest python-neovim is installed: 0.1.13
36
27
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
36
27

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?