From 19c1a29c303864018ab82da2012a3101ad4eb036 2021-07-13 00:46:39 From: Arthur Svistunov Date: 2021-07-13 00:46:39 Subject: [PATCH] Fix path handling in `pip` line magic (#13052) * Fix path handling in `pip` line magic * Remove unused import * code style fix * Remove `_get_full_path()` (`sys.executable` is always absolute) * Quote executable path selectively, leaving whitespaces untouched. * forgotten join * reduce shlex usage - remove line split, leave only path quotation --- diff --git a/IPython/core/magics/packaging.py b/IPython/core/magics/packaging.py index e5e6877..f1b1954 100644 --- a/IPython/core/magics/packaging.py +++ b/IPython/core/magics/packaging.py @@ -66,7 +66,9 @@ class PackagingMagics(Magics): 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