Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an advantage of using `%` over `!` in jupyter when the same command exists for both?

For example when I use !pip install ... VSCode suggests me to use %pip install .... Similarly there is a version of mv for both ! and %. Is there an advantage to use one over the other?

like image 480
Yesh Avatar asked Sep 14 '25 19:09

Yesh


1 Answers

Yes, %pip will properly resolve the appropriate virtual environment (the one that is used by the current kernel) in most edge cases, while !pip will not and you may end up installing packages in incorrect locations.

Some references:

  • Authoritative statement from creator of IPython/Jupyter
  • Blog post from creator of %pip magic
  • The actual pull request that introduced the %pip and %conda magics
like image 125
krassowski Avatar answered Sep 17 '25 08:09

krassowski