您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在vim中设置python virtualenv

在vim中设置python virtualenv

这是我使用的(很抱歉,突出显示内容很奇怪)。

" Function to activate a virtualenv in the embedded interpreter for
" omnicomplete and other things like that.
function LoadVirtualEnv(path)
    let activate_this = a:path . '/bin/activate_this.py'
    if getftype(a:path) == "dir" && filereadable(activate_this)
        python << EOF
import vim
activate_this = vim.eval('l:activate_this')
execfile(activate_this, dict(__file__=activate_this))
EOF
    endif
endfunction

" Load up a 'stable' virtualenv if one exists in ~/.virtualenv
let defaultvirtualenv = $HOME . "/.virtualenvs/stable"

" Only attempt to load this virtualenv if the defaultvirtualenv
" actually exists, and we aren't running with a virtualenv active.
if has("python")
    if empty($VIRTUAL_ENV) && getftype(defaultvirtualenv) == "dir"
        call LoadVirtualEnv(defaultvirtualenv)
    endif
endif

请注意,您需要针对用于virtualenv的Python编译MacVim,例如,如果您从Python.org下载了Python 2.7,则应使用--with-python-config- dir=/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config作为参数重新编译MacVim./configure

希望有帮助!

只需注明 写这个小东西的许多侦探工作都是由这个博客完成的,他应该得到一些荣誉。

python 2022/1/1 18:28:23 有187人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶