-m flag

The interpreter option python -m name, which finds a module on the module search path and runs it as a program.

In more detail

python -m pip, python -m venv, python -m idlelib and python -m pytest run tools as modules of the exact interpreter you typed, avoiding PATH confusion. Running your own package with python -m mypkg.main keeps its imports working.

Example

python -m pip install requests

Related terms

Taught in

References