简体   繁体   中英

vim8: update PYTHONPATH in vimrc only

Because of some restrictions on my work server, I can't install python packages system wide. I'm using pyenv to have some additional features (like neovim's python package) and I'm currently exporting PYTHONPATH=path/to/my/env/lib/site-packages in my bashrc to make vim happy.

However, I'd like to avoid updating my PYTHONPATH globally, and (if that's possible) only update it in my .vimrc, so that only vim/vim's plugin are using the additional packages.

Is that possible ? How can I update vim's python configuration ?

So far I tried to use g:python3_host_prog and set it to path/to/my/env/bin/python but vim is still using the system one. As I am using a source build vim, should I set some option at compile time to point to the right python ?

I do this (in Neovim):

let g:python_host_prog = expand($XDG_DATA_HOME).'/virtualenvs/nvimp2-sk9zInl9/bin/python'
let g:python3_host_prog = expand($XDG_DATA_HOME).'/virtualenvs/nvimp3-VnFM7OAS/bin/python'

having created the respective virtualenvs (using pipenv if memory serves) and XDG_DATA_HOME gets set to ~/.local/share in .profile . So I can certify that setting these values definitely works (and the output of :checkhealth is correct). However, I don't build Vim from source.

I imagine you've already seen it, but just in case: Setting up Python for Neovim .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM