From 57cbf1421f82491cf74e5694593a1778780f6c3c Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 1 Apr 2018 12:58:00 +0200 Subject: [PATCH] Somehow the virtual env prefix is set in VIM. This basically corrupts VIM's Python, because it might be having a differnet prefix (Python 3.6) than sys path. I don't know who came up with this - probably it's just how Python loads venvs - but it's definitely not good. Fortunately we can just reset it and be happy. --- pythonx/jedi_vim.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pythonx/jedi_vim.py b/pythonx/jedi_vim.py index adacde3..6da6ba4 100644 --- a/pythonx/jedi_vim.py +++ b/pythonx/jedi_vim.py @@ -25,6 +25,15 @@ else: ELLIPSIS = u"…" +try: + sys.prefix = sys.base_prefix + sys.exec_prefix = sys.base_exec_prefix +except AttributeError: + # Somehow sys.prefix is set in combination with VIM and virtualenvs. + # However the sys path is not affected. Just reset it to the normal value. + pass + + class PythonToVimStr(unicode): """ Vim has a different string implementation of single quotes """ __slots__ = []