sys.prefix

The folder a running Python treats as its installation; inside a virtual environment it differs from sys.base_prefix.

In more detail

Comparing sys.prefix with sys.base_prefix answers am I in a virtual environment: equal outside one, different inside one. The course uses this pair because it asks Python itself instead of trusting the prompt.

Example

import sys
print(sys.prefix != sys.base_prefix)

Related terms

Taught in

References