0

I see this is a notebook file:

%pip install wordcloud

I would usually do: pip install wordcloud without the %.

I have tried looking this up, but cannot seem to find it. What does the % actually do ? is it notebook specific ?

EDIT: there are 4 proposed solutions (that were similar). it appears as though the % is a replacement in the notebook for cmd, but this does not explain its usage, in particular this:

so the % effectively replaces the cmd ? but i dont get why it is used given that the pip command is only needed to be run once ? is it proposed that this pip is run every time (to install the latest version)...

So: why use %pip in place of pip install?, what is the benefit ?

D.L
  • 4,339
  • 5
  • 22
  • 45
  • 1
    to the best of my understanding, this is indeed notebook specific, as you pointed out. anyway, I doubt python interpreter would ever recognize `pip` command – alphamu Oct 20 '22 at 18:55
  • 1
    These are not notebook specific, it is an ipython magic: https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-pip – wim Oct 20 '22 at 18:56
  • The rationale for adding a %pip magic is discussed here: https://github.com/ipython/ipython/pull/11524 – wim Oct 20 '22 at 21:23

1 Answers1

0

This is a so called "magic" command and specific to the ipython kernel for jupyter notebooks.

You can read more about it here: https://ipython.readthedocs.io/en/stable/interactive/magics.html

lhk
  • 27,458
  • 30
  • 122
  • 201
  • so the `%` effectively replaces the `cmd` ? but i dont get why it is used given that the `pip` command is only run once ? is it proposed that this pip is run every time (to install the latest version).... ? – D.L Oct 20 '22 at 20:04