Install packages, pin versions and manage virtual environments in Python — the pip and conda commands you need.
pip install requestsInstall a packagepip install requests==2.31.0Install a specific versionpip install -r requirements.txtInstall everything in a requirements filepip install -U requestsUpgrade a package to the latestpip uninstall requestsRemove a packagepip listList installed packagespip show requestsShow details about a packagepip freeze > requirements.txtSave exact versions to a filepip install --user requestsInstall for your user onlypython -m venv venvCreate a virtual environmentsource venv/bin/activateActivate it (macOS / Linux)venv\\Scripts\\activateActivate it (Windows)deactivateLeave the virtual environmentconda create -n env python=3.11Create a named environmentconda activate envActivate an environmentconda install numpyInstall a package with condaconda env listList your environmentsconda env export > environment.ymlExport the environment to a filePython projects pull in libraries with pip, the standard package installer. The everyday commands are pip install to add a package, pip install -r requirements.txt to set up a project from its dependency list, and pip freeze to record exact versions so others can reproduce your setup. Pinning versions and sharing a requirements file is what keeps a project working the same way on every machine.
Installing packages globally leads to conflicts between projects, which is why virtual environments exist — isolated spaces where each project keeps its own dependencies. Create one with python -m venv venv and activate it, or use conda if you work in data science, where it manages both Python versions and non-Python libraries. Either way, activate the environment before installing, and your projects stay cleanly separated.