Python Command Reference
Python Common command Quick Reference,
python -m venv .venv |
|
source .venv/bin/activate |
(Linux/Mac) |
.venv\Scripts\activate |
(Windows) |
deactivate |
|
python --version |
Python |
which python |
Python |
python -m venv --clear .venv |
|
pip install <package> |
|
pip install -r requirements.txt |
|
pip install -U <package> |
New |
pip uninstall <package> |
|
pip freeze > requirements.txt |
|
pip list --outdated |
|
pip show <package> |
|
uv pip install <package> |
uv |
python app.py |
|
python -m <module> |
|
python -c "code" |
|
python -i app.py |
|
python -m pdb app.py |
|
breakpoint() |
(3.7+) |
python -m cProfile -s cumulative app.py |
|
pytest |
|
pytest -x |
|
pytest -v |
|
pytest --cov=src |
|
pytest -k 'test_login' |
|
pytest --lf |
|
python -m unittest discover |
unittest |
ruff format . |
() |
ruff check --fix . |
Lint |
black . |
Black |
mypy src/ |
|
mypy --strict . |
|
python -m py_compile app.py |
Syntax |
python -m compileall src/ |
Syntax |
python -m http.server 8000 |
HTTP |
python -m json.tool data.json |
JSON |
python -m timeit 'code' |
|
python -m zipfile -c out.zip dir/ |
zip |
python -m base64 file.bin |
Base64 |
python -m webbrowser http://localhost:8000 |
|
python -m pip check |
|