From 0f2a7215bb495c504890d8e6d3906bf0e4e4f022 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Thu, 2 Apr 2020 20:59:35 +0200 Subject: [PATCH] Use the interpreter environment if the executable is not available, fixes #1531 --- jedi/api/environment.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jedi/api/environment.py b/jedi/api/environment.py index 3ab2bf80..3c0339b5 100644 --- a/jedi/api/environment.py +++ b/jedi/api/environment.py @@ -254,7 +254,14 @@ def get_cached_default_environment(): @time_cache(seconds=10 * 60) # 10 Minutes def _get_cached_default_environment(): - return get_default_environment() + try: + return get_default_environment() + except InvalidPythonEnvironment: + # It's possible that `sys.executable` is wrong. Typically happens + # when Jedi is used in an executable that embeds Python. For further + # information, have a look at: + # https://github.com/davidhalter/jedi/issues/1531 + return InterpreterEnvironment() def find_virtualenvs(paths=None, **kwargs):