Skip to content

Commit

Permalink
Fix path handling in pip line magic (#13052)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
madbird1304 committed Jul 13, 2021
1 parent 286a87e commit 19c1a29
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion IPython/core/magics/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,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
Expand Down

0 comments on commit 19c1a29

Please sign in to comment.