nerdexam
Microsoft

DP-100 · Question #354

You are authoring a notebook in Azure Machine Learning studio. You must install packages from the notebook into the currently running kernel. The installation must be limited to the currently…

The correct answer is B. %pip. The %pip IPython line magic installs packages directly into the Python environment of the currently running kernel, ensuring the installation is scoped to that kernel only. The !pip shell escape runs pip as a subprocess, which may target a different Python environment than the…

Explore data and run experiments

Question

You are authoring a notebook in Azure Machine Learning studio. You must install packages from the notebook into the currently running kernel. The installation must be limited to the currently running kernel only. You need to install the packages. Which magic function should you use?

Options

  • A!pip
  • B%pip
  • C!conda
  • D%load

How the community answered

(61 responses)
  • A
    2% (1)
  • B
    89% (54)
  • C
    3% (2)
  • D
    7% (4)

Explanation

The %pip IPython line magic installs packages directly into the Python environment of the currently running kernel, ensuring the installation is scoped to that kernel only. The !pip shell escape runs pip as a subprocess, which may target a different Python environment than the active kernel - leading to packages being installed in the wrong environment. !conda similarly runs in a shell subprocess without kernel scoping. %load is used to load the contents of a file into a notebook cell, not to install packages.

Topics

#Azure ML Notebooks#Package management#IPython magic commands#Kernel environment

Community Discussion

No community discussion yet for this question.

Full DP-100 Practice