Databricks Machine Learning Associate Question 44
Single answerYou are working on a Databricks cluster and need to install a Python library so that it is available to all notebooks running on the cluster. Which of the following steps should you take to correctly achieve this?
- A
Use the %pip magic command within a notebook to install the library.
- B
Navigate to the Libraries tab in the cluster settings and install the library from there.
- C
Use the Databricks CLI to install the library directly on the cluster.
- D
Restart the cluster and manually upload the library files to the workspace.
Show answer and explanation
Correct answer: B
Explanation
To make a Python library available to all notebooks running on a Databricks cluster, you should install it through the Libraries tab in the cluster settings. This ensures the library is installed at the cluster level and is accessible across all notebooks using that cluster. Other methods like %pip are notebook-specific and not applicable for cluster-wide installation.
- A. Incorrect.
Using the %pip magic command installs the library only for the notebook where the command is run, not for all notebooks on the cluster.
- B. Correct.
Navigating to the Libraries tab in the cluster settings allows you to install the library at the cluster level, making it available to all notebooks running on that cluster.
- C. Incorrect.
The Databricks CLI is not used for directly installing libraries on a cluster. It is primarily used for managing Databricks resources such as jobs or files.
- D. Incorrect.
Manually uploading library files and restarting the cluster is not a recommended or standard way to install libraries on a Databricks cluster.