diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 61e1541..2619883 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -772,10 +772,13 @@ class InteractiveShell(SingletonConfigurable): # stdlib venv may symlink sys.executable, so we can't use realpath. # but others can symlink *to* the venv Python, so we can't just use sys.executable. # So we just check every item in the symlink tree (generally <= 3) + current_dir = Path(os.curdir).absolute() paths = [p] while p.is_symlink(): - p = Path(os.readlink(p)) - paths.append(p.resolve()) + os.chdir(p.parent) + p = Path(os.readlink(p)).absolute() + paths.append(p) + os.chdir(current_dir) # In Cygwin paths like "c:\..." and '\cygdrive\c\...' are possible if p_venv.parts[1] == "cygdrive":