Python venv Cheat Sheet/Show sys.prefix and sys.base_prefix

Confirm whether you are inside a venv.

Section: Inspect the environment

Show sys.prefix and sys.base_prefix

bash
bash
python -c "import sys; print(sys.prefix); print(sys.base_prefix)"
Explanation

Inside a venv, `sys.prefix` usually points to the venv and `sys.base_prefix` to the base interpreter.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Inspect the environment
Show active Python version
Print the Python version from the current environment.
OpenIn sheetbashsame section
Show interpreter executable path
Print the executable path for the active interpreter.
OpenIn sheetbashsame section
Show site-packages paths
Print the active site-packages directories.
OpenIn sheetbashsame section
Show pip path and version
Confirm pip belongs to the active environment.
OpenIn sheetbashsame section
List installed packages
Show packages currently installed in the environment.
OpenIn sheetbashsame section
Show one package
Display metadata for an installed package.
OpenIn sheetbashsame section