Databricks Machine Learning Associate Question 43
Single answerYou want to install a Python library so that it is available to all notebooks running on a Databricks cluster. Which method should you use?
- A
Use the %pip install command in a notebook cell
- B
Navigate to the cluster configuration page, add the library under the 'Libraries' tab, and restart the cluster
- C
Create a Databricks job to install the library for all notebooks
- D
Install the library in one notebook and share the notebook with other users
Show answer and explanation
Correct answer: B
Explanation
To make a Python library available to all notebooks running on a Databricks cluster, you must install it at the cluster level using the cluster configuration interface. This ensures that the library is available in the environment of all notebooks that use this cluster. Other methods, such as %pip install or installing in a single notebook, only apply to specific sessions and do not affect the cluster-wide environment.
- A. Incorrect.
%pip install installs the library only in the current notebook session. It does not make the library available to all notebooks in the cluster.
- B. Correct.
Adding the library in the cluster configuration under the 'Libraries' tab ensures the library is installed at the cluster level and is available to all notebooks running on the cluster.
- C. Incorrect.
Databricks jobs are used for scheduling and running computations, not for installing libraries.
- D. Incorrect.
Installing the library in one notebook does not make it available to other notebooks, even if the notebook is shared.