How Do You Add the NLTK Library to a Vertex AI Workbench Jupyter Kernel?

You are working on a prototype of a text classification model in a managed Vertex AI Workbench notebook. You want to quickly experiment with tokenizing text by using a Natural Language Toolkit (NLTK) library. How should you add the library to your Jupyter kernel?

  1. Install the NLTK library from a terminal by using the pip install nltk command.
  2. Write a custom Dataflow job that uses NLTK to tokenize your text and saves the output to Cloud Storage.
  3. Create a new Vertex AI Workbench notebook with a custom image that includes the NLTK library.
  4. Install the NLTK library from a Jupyter cell by using the !pip install nltk --user command. Source Reference Answer

Community Votes

D
100%

100% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

The exam tests matching package-installation weight to the scenario — quick prototyping calls for an in-cell !pip install --user, and the trap is over-engineering with custom images or Dataflow pipelines.

For quick prototyping in a managed Vertex AI Workbench notebook, the fastest way to add NLTK is running !pip install nltk --user in a Jupyter cell, which installs the library into the kernel's user space. The community unanimously (100% of votes) backs this approach over terminal installs, custom images, or Dataflow jobs.

Choosing A (terminal `pip install nltk`) — it seems equivalent, but a terminal shell can point to a different Python environment than the running Jupyter kernel, and without the `--user` flag it may hit permission issues or conflict with system-wide packages on managed notebooks.

Community Discussion (4 comments)

pikachu007 👍 7 Selected: D
Direct Installation: It installs the library directly within the notebook environment, making it immediately available for use. Simplicity: It requires a single command in a Jupyter cell, eliminating the need for external tools or configuration. User-Specific Installation: The --user flag ensures the library is installed in your user space, avoiding conflicts with system-wide packages.
forport 👍 1 Selected: D
Right command : !pip install nltk --user
fitri001 👍 1 Selected: D
Efficiency: It allows installation directly within your notebook cell, minimizing setup time compared to creating a custom image or using an external terminal. User-Level Installation: Using --user ensures the library is installed within your user environment, avoiding conflicts with system-wide installations or impacting other users.
tavva_prudhvi 👍 3 Selected: D
This command installs the NLTK library directly from within your Jupyter notebook, allowing you to quickly proceed with your text tokenization experiments without needing to manage Docker images or set up external data processing jobs. The --user flag ensures that the library is installed in the user's space, avoiding potential conflicts with system-wide packages.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

Option D installs NLTK directly from a Jupyter cell with !pip install nltk --user, placing the package in the user site-packages of the exact Python environment backing the running kernel, making it immediately importable. The question explicitly frames the task as a prototype where you want to "quickly experiment," so minimal setup overhead is the deciding factor. Comment [1] (7 likes) breaks down the three winning properties: direct installation, one-command simplicity, and the --user flag that avoids conflicts with system-wide packages. Comment [2] reinforces that this approach lets you start tokenizing immediately without managing Docker images or setting up external data-processing jobs.

Why the Other Options Are Wrong

Option A installs from a terminal, which may target a different Python environment than the active Jupyter kernel and lacks the --user flag that sidesteps permission issues in managed notebooks. Option B builds a custom Dataflow job, which is a large-scale batch-processing service — massive overkill for prototyping, and it never adds NLTK to your kernel at all. Option C creates a new notebook with a custom container image; while valid for production reproducibility, building and pushing a custom image is far too slow for quick experimentation. The scenario keywords "prototype" and "quickly" rule out every heavyweight option.

Community Comment Notes

Community consensus is unanimous: 100% of votes favor D, and every comment endorses it. Comment [3] simply confirms the exact command, while comment [4] — despite a typo labeling it E — describes the same !pip install --user approach and stresses efficiency and user-level installation. No comment argues for any alternative, making D a safe, high-confidence answer.

Official Reference

Exam Strategy

Scan the scenario for urgency words like "quickly," "prototype," or "experiment" — they signal the lightest-weight solution that touches the notebook kernel directly. In-cell !pip install <package> --user is the go-to for ad-hoc libraries, while custom images and Dataflow are reserved for reproducibility and scale. Match solution weight to scenario scope and the distractors eliminate themselves.

Related Analysis

Practice All PMLE Questions

Access 65 questions with complete answers and detailed explanations.

View Full PMLE Practice Test →

← Back to PMLE Study Guide