From 912345e91cdfb68db1dd79b0510cc6312435d3bb Mon Sep 17 00:00:00 2001 From: Arthur Svistunov Date: Tue, 13 Jul 2021 02:46:39 +0200 Subject: [PATCH] Backport PR #13052: Fix path handling in `pip` line magic --- IPython/core/magics/packaging.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/IPython/core/magics/packaging.py b/IPython/core/magics/packaging.py index cfee7865f5d..84285a373cb 100644 --- a/IPython/core/magics/packaging.py +++ b/IPython/core/magics/packaging.py @@ -65,7 +65,9 @@ def pip(self, line): Usage: %pip install [pkgs] """ - self.shell.system(' '.join([sys.executable, '-m', 'pip', line])) + python = shlex.quote(sys.executable) + self.shell.system(" ".join([python, "-m", "pip", line])) + print("Note: you may need to restart the kernel to use updated packages.") @line_magic