ipython
ipython copied to clipboard
Built-in magic commands do not escape spaces in path
It does work with shell commands (e.g. !pip instead of %pip), but when using the magic commands spaces are not escaped.
In macOS Big Sur, a brand new virtualenv with spaces in its path:
$ pip list
Package Version
---------------- -------
appnope 0.1.2
backcall 0.2.0
decorator 5.0.6
ipykernel 5.5.3
ipython 7.22.0
ipython-genutils 0.2.0
jedi 0.18.0
jupyter-client 6.1.12
jupyter-core 4.7.1
parso 0.8.2
pexpect 4.8.0
pickleshare 0.7.5
pip 19.2.3
prompt-toolkit 3.0.18
ptyprocess 0.7.0
Pygments 2.8.1
PyQt5 5.15.4
PyQt5-Qt5 5.15.2
PyQt5-sip 12.8.1
python-dateutil 2.8.1
pyzmq 22.0.3
qtconsole 5.0.3
QtPy 1.9.0
setuptools 41.2.0
six 1.15.0
tornado 6.1
traitlets 5.0.5
wcwidth 0.2.5
$ ipython
Python 3.8.2 (default, Jun 2 2020, 13:57:42)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.22.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: !pip --version
pip 19.2.3 from /Users/microbit-carlos/workspace/deleteme/really-delete/path with spaces/.venv/lib/python3.8/site-packages/pip (python 3.8)
In [2]: %pip --version
zsh:1: no such file or directory: /Users/microbit-carlos/workspace/deleteme/really-delete/path
Note: you may need to restart the kernel to use updated packages.
In [3]: pip --version
zsh:1: no such file or directory: /Users/microbit-carlos/workspace/deleteme/really-delete/path
Note: you may need to restart the kernel to use updated packages.
Closest open issue i've found is this one, but in that it looks like the spaces are escaped incorrectly? https://github.com/ipython/ipython/issues/11138
It can also fail the same way if a path is not quoted when running shell command:
$ ipython
Python 3.8.2 (default, Jun 2 2020, 13:57:42)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.22.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import sys
In [2]: !{sys.executable} -m pip --version
zsh:1: no such file or directory: /Users/microbit-carlos/workspace/deleteme/really-delete/path
In [3]: !'{sys.executable}' -m pip --version
pip 19.2.3 from /Users/microbit-carlos/workspace/deleteme/really-delete/path with spaces/.venv/lib/python3.8/site-packages/pip (python 3.8)
I think this bug can be marked as fixed.