Courseiva
Modules and Packages →mediumMultiple Choice

PCAP Modules and Packages Practice Question

Exhibit

Exhibit:
$ pip list
Package    Version
---------- -------
numpy      1.24.0
pandas     1.5.3
pip        22.0.4

Refer to the exhibit. A developer runs 'pip install pandas==2.0.0' but gets an error stating that the required version is not available. Which command should be used to list all available versions of pandas?

⚠ Common exam trap

Python Institute often tests the distinction between commands that query the remote index (`pip index`) versus commands that inspect the local environment (`pip show`, `pip list`), and candidates frequently confuse `pip search` (which searches package names) with listing versions.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

pip index versions pandas

`pip index versions pandas` is the command that queries the Python Package Index (PyPI) for all available versions of the specified package. This command was introduced in pip 21.1 and is the proper way to list version history without attempting to install.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    pip index versions pandas

    Why this is correct

    pip index versions pandas is correct because it contacts the configured package index (PyPI by default) and fetches the release history for the pandas project, listing every available version in ascending order. This is the only option that actually asks the remote index about versions, and it is the pip-native way to check which releases exist before installing or pinning one. Note that this subcommand is experimental, but it is still the right choice among the four.

  • ✗

    pip search pandas

    Why it's wrong here

    pip search pandas is wrong because the search subcommand was removed from pip in version 21.0; it relied on PyPI's legacy XML-RPC search API, which is no longer supported. Even in older pip versions it only matched project names and descriptions containing 'pandas', not the list of releases, so it could never produce a version listing. Modern pip will reject the command as unknown, rather than showing anything useful.

  • ✗

    pip show pandas

    Why it's wrong here

    pip show pandas is wrong because it displays metadata for a pandas distribution already installed in the current environment, such as its version, location, and dependencies, by reading from site-packages. It does not contact any package index, so it has no information about the versions that could be installed. If pandas has not been installed, pip show simply exits with an error saying that no package was found.

  • ✗

    pip list --all pandas

    Why it's wrong here

    pip list --all pandas is an invalid invocation because pip list does not support an --all flag and does not accept a package name as a positional argument; its purpose is to enumerate the installed distributions in the environment. The --all option also does not exist for this command in modern pip, so pip will fail with an unrecognized-options error. Even with valid flags, pip list only reports local packages, so it cannot reveal the version history available on PyPI.

About these practice questions

One of 421 original PCAP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.