brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: python -m venv --upgrade-deps starts a venv with a current pip

Python
~/tips/tip-python-venv-upgrade-deps

python3 -m venv --upgrade-deps .venv

Creates a virtual environment and upgrades pip in it immediately, so installs start from a current version.

A fresh virtual environment often ships the pip version that came bundled with the interpreter. I add one flag so the venv starts with a newer one.

python3 -m venv --upgrade-deps .venv
.venv/bin/python -m pip --version

--upgrade-deps upgrades pip inside the new environment right after it is created (on Python before 3.12 it also upgrades setuptools). It needs network access to PyPI at creation time. Calling .venv/bin/python -m pip directly means you use that environment’s pip without activating anything, which is handy in scripts and cron jobs. On Debian and Ubuntu you need the python3-venv package installed first.

Further reading: venv documentation

More Python tips import asyncio from enum import StrEnum, auto except* ValueError as eg: import pytest pytest --maxfail=2 All Python tips (107) All topics

Link