LoginSignup
12
9

More than 5 years have passed since last update.

Vim の Python 3 インターフェイスとして embeddable な Python を使う

Last updated at Posted at 2016-10-22

問題

Windows の話。
ふだん Python 環境は Anaconda に頼っているので、当然 Vim の Python 3 インターフェイスとしても Anaconda の Python 3.5 を参照させたいが、VC10 (Vim)、VC14 (Anaconda) とVCのバージョンが違うため gVimから Anaconda の python35.dll を使おうとすると Vim 起動時に落ちてしまって出来ない。

Vim を VC14 でコンパイルすれば解決するかもしれないが、Kaoriya さん配布のバイナリが使えないのはつらいので、Anaconda ではない素の Python (こちらはVC10) を別途インストールして凌いでいた。

しかし、Anaconda が圧倒的に便利で、素の Python は使わないため、できればインストールしたくない。

対応

https://www.python.org/downloads/windows/
上記で配布されている Windows x86 embeddable zip file をダウンロードして、
Vim のインストールディレクトリに以下の2ファイルを置く。

  • python35.dll
  • python35.zip

一種のインストールと言えなくもないが、2ファイル置くだけだし、コンパイルもパスを通す必要もない。これで Python インターフェースが使えるようになる。

netupvimdiffpt なんかも置いてあるので、この際 Vimのディレクトリが汚れるのは気にしない。

その他

後は、これまで同様に、こちらなどを参考に jedi.vim から Anaconda が見えるよう ftplugin/python.vim を設定しておく。
http://qiita.com/repli/items/2bc6986f0be94555348a

Mac の場合は、brew install python3 し、
pythonthreedllpythonthreehome を設定する。

.vimrc
if has('vim_starting')
    if has('macunix')
        " brew install python3
        set pythonthreedll=
            \/usr/local/Cellar/python3/3.6.4_2/
            \Frameworks/Python.framework/Versions/3.6/Python
        set pythonthreehome=
            \/usr/local/Cellar/python3/3.6.4_2/
            \Frameworks/Python.framework/Versions/3.6

    elseif has('win32')
        " embed 版のpython をダウンロードして vim と同じフォルダに置く。
        "   python35.dll
        "   python35.zip

    endif
endif
12
9
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
12
9