# Environments, Packages and Jupyter

> Isolated environments, dependency management and working productively in notebooks without creating an unreproducible mess. Free notes, key concepts, resources...

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/environments-and-notebooks
Last updated: 2026-11-28

Isolated environments, dependency management and working productively in notebooks without creating an unreproducible mess.

Beginner · about 5 hours · difficulty 1/5

Learn first: [Python for Machine Learning](https://www.internhack.in/roadmaps/tracks/machine-learning/python-for-ml)

ML projects depend on many fast-moving libraries (NumPy, PyTorch, CUDA builds). Without isolated environments you will eventually break one project by upgrading another. Pick one tool and use it for every project.

### Environment options

- **venv + pip**: built into Python, fine for most CPU work. Pin versions in `requirements.txt`.
- **uv**: a very fast drop-in for pip/venv with lockfiles; a great modern default.
- **conda / mamba**: useful when you need non-Python binaries (CUDA toolkits, GDAL).

### Jupyter

Notebooks are ideal for exploration: run a cell, look at a plot, adjust. JupyterLab, VS Code notebooks and Google Colab (free GPU) are all fine. Learn the kernel concept, magic commands like `%timeit`, and restarting the kernel to confirm your notebook runs top to bottom.

### Pitfalls

- Hidden state: cells run out of order produce results nobody can reproduce. Use **Restart and Run All** before trusting a result.
- Installing packages into the global interpreter or mixing conda and pip carelessly.
- Keeping all logic in notebooks forever. Move stable code into `.py` modules and import it.

**Good enough to move on** when you can create a fresh environment from a requirements or lock file on a new machine and reproduce a notebook result.

## Key concepts

- **venv and pip**
- **uv**: Fast installs and lockfiles
- **conda or mamba**
- **JupyterLab and VS Code notebooks**
- **Google Colab and Kaggle notebooks**: Free GPUs
- **Pinning and lockfiles**

## Mini project

Create a project folder with a pinned environment, a notebook that loads a dataset, and a README explaining how a teammate recreates the environment and runs the notebook end to end.

## Check yourself

Your notebook gives a different result after Restart and Run All. What most likely happened?

## Free resources

- [venv: Creation of virtual environments](https://docs.python.org/3/library/venv.html) (python.org)
- [uv documentation](https://docs.astral.sh/uv/) (Astral)
- [Project Jupyter documentation](https://docs.jupyter.org/en/latest/) (Jupyter)

Previous: [Python for Machine Learning](https://www.internhack.in/roadmaps/tracks/machine-learning/python-for-ml) · Next: [NumPy and Array Thinking](https://www.internhack.in/roadmaps/tracks/machine-learning/numpy)

## More in Python and the Data Workbench

- [Python for Machine Learning](https://www.internhack.in/roadmaps/tracks/machine-learning/python-for-ml)
- [Environments, Packages and Jupyter](https://www.internhack.in/roadmaps/tracks/machine-learning/environments-and-notebooks)
- [NumPy and Array Thinking](https://www.internhack.in/roadmaps/tracks/machine-learning/numpy)
- [pandas for Tabular Data](https://www.internhack.in/roadmaps/tracks/machine-learning/pandas)
- [Visualization with Matplotlib and Seaborn](https://www.internhack.in/roadmaps/tracks/machine-learning/data-visualization)
- [Git for ML Projects](https://www.internhack.in/roadmaps/tracks/machine-learning/git-for-ml)
- [SQL for Pulling Training Data](https://www.internhack.in/roadmaps/tracks/machine-learning/sql-for-data)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
