pip and Virtual Environments in Python
pip is Python's package installer, used to add third-party libraries — like requests or pandas — that aren't part of the standard library. A virtual environment is an isolated, self-contained installation of Python and its packages for one specific project, so different projects can depend on different (even conflicting) package versions without interfering with each other.
python -m venv env_name
Creates a new virtual environment in a folder called env_name.
Activate it
A command that differs by operating system, making that isolated environment the one currently in use.
pip install package_name
Installs a package into whichever environment is currently active.
pip freeze > requirements.txt
Saves a list of exactly what's installed, so it can be recreated elsewhere.
pip install -r requirements.txt
Installs every package listed in that file, recreating the same environment on another machine.
python -m venv myenvsource myenv/bin/activatepip install requestspip freeze > requirements.txtRecommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in Python yourself — building beats watching.