Tools & Setup
You can learn this whole course in your browser, because every python tryit example runs there. For your own projects, though, you will want a proper setup on your computer or in the cloud.
In this lesson you will meet the main tools data scientists use, learn how notebooks work, and install the libraries with uv or pip.
Where to write data science code
| Tool | Runs on | Good for | Watch out for |
|---|---|---|---|
| This site's Try-it editor | Your browser | Learning and quick experiments | No internet access from Python, no saving |
| Google Colab | Google's cloud servers | Starting fast on any computer, free GPU time for ML | Needs a Google account; uploaded files are lost when the session ends |
| JupyterLab / Jupyter Notebook | Your computer | Exploring data step by step with charts inline | Cells run out of order can confuse you |
| VS Code | Your computer | Notebooks and normal .py files in one editor, Git, debugging | Needs the Python and Jupyter extensions |
Plain .py scripts | Anywhere | Repeatable reports, scheduled jobs, production | No inline charts while exploring |
Most people use more than one: a notebook while exploring, then a .py script once the analysis is final and needs to run every week.
How notebooks work
A notebook (a file ending in .ipynb) is a document made of cells. A code cell holds Python; a Markdown cell holds headings and notes. When you run a cell, its output, including tables and charts, appears right under it. Behind the notebook a Python process called the kernel keeps all your variables in memory between cells.
Two notebook habits differ from normal Python:
- The last line of a cell is displayed automatically. If a cell ends with
sales.head(), the notebook shows a formatted table withoutprint(). In a.pyscript, and in this site's editor, you must callprint()yourself. - Run order matters, not cell position. If you run cell 5, then change cell 2 and do not rerun it, your variables no longer match the code you see. Before you share a notebook, use "Restart kernel and run all cells" to prove it works from top to bottom.
Installing with uv
uv is a fast tool that creates a project folder, a private environment and a lock file of exact package versions in a few commands. After installing uv from its official site, run these commands in a terminal:
uv init sales-analysis
cd sales-analysis
uv add numpy pandas matplotlib scipy
uv add --dev jupyterlab
uv run jupyter labuv init creates the project with a pyproject.toml file. uv add installs packages into the project's own environment and records them, so a classmate can recreate exactly the same setup with uv sync. jupyterlab is added as a development tool because you need it to explore, not to run the final script. uv run jupyter lab starts JupyterLab inside that environment and opens it in your browser.
Installing with pip
pip is the standard installer that comes with Python. Use it inside a virtual environment, a private folder of packages for one project, so projects do not break each other.
python -m venv .venv
.venv\Scripts\activate
pip install numpy pandas matplotlib scipy jupyterlab
jupyter labThe second line is for Windows. On macOS and Linux, activate with source .venv/bin/activate instead. To use the same environment in VS Code, open the folder, install the Python and Jupyter extensions, create a file ending in .ipynb, and pick .venv as the kernel in the top-right corner.
Check your versions
Whichever tool you use, check which versions you have. Behaviour changed in NumPy 2 and pandas 3, so an old tutorial may show different output from your computer. Run this in the browser editor:
import platform
import numpy as np
import pandas as pd
import matplotlib
import scipy
print("Python ", platform.python_version())
print("NumPy ", np.__version__)
print("pandas ", pd.__version__)
print("matplotlib", matplotlib.__version__)
print("SciPy ", scipy.__version__)Python 3.14.2 NumPy 2.4.6 pandas 3.0.2 matplotlib 3.10.8 SciPy 1.18.0
The browser editor runs Python 3.14 compiled to WebAssembly, with the same library versions this course teaches.
Standard import names
Every data scientist uses the same short names when importing. Stick to them, because every tutorial, answer and colleague will expect them.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
marks = np.array([72, 85, 64, 91])
table = pd.DataFrame({"student": ["Aarav", "Priya", "Kabir", "Meera"], "marks": marks})
print(table)
print("Class average:", marks.mean())
plt.bar(table["student"], table["marks"])
plt.title("Marks in the unit test")
plt.show()student marks 0 Aarav 72 1 Priya 85 2 Kabir 64 3 Meera 91 Class average: 78.0
np, pd and plt are conventions, not rules, but writing import pandas as panda would only confuse readers. The bar chart appears as an image: Meera's bar is the tallest and Kabir's the shortest.
Common mistakes
- Installing packages globally. Running
pip installwithout a virtual environment mixes packages from every project and leads to version clashes. Useuvor a.venv. - Installing into the wrong Python. In a notebook,
%pip installinstalls into the kernel the notebook is using;!pip installmay install somewhere else. - Expecting notebook display in a script. A bare
df.head()on the last line shows nothing in a.pyfile. Useprint(df.head()). - Sharing a notebook that only works out of order. Restart and run all cells before you send it.
Key points
- Use the browser editor to learn, Google Colab for zero setup, and JupyterLab or VS Code for your own projects.
- A notebook is made of cells; the kernel keeps variables between them, and the last expression in a cell is displayed.
uv init,uv addanduv runcreate a reproducible project;pipwith a virtual environment also works.- Check versions with
np.__version__andpd.__version__, because NumPy 2 and pandas 3 changed some behaviour. - Import with the standard names
np,pdandplt.
Exercise
Write a small program for the browser editor that imports NumPy and pandas with their standard names, creates a NumPy array of the daily footfall at a Lucknow bookshop for one week (any seven numbers), prints the total and the average, and prints the pandas version.
Show solution
import numpy as np
import pandas as pd
footfall = np.array([120, 95, 102, 130, 160, 210, 190])
print("Total visitors:", footfall.sum())
print("Average per day:", footfall.mean())
print("pandas", pd.__version__)Total visitors: 1007 Average per day: 143.85714285714286 pandas 3.0.2
sum() and mean() work on the whole array at once. In a notebook you could leave out print() on the last line, but in a script or this editor you need it.
Quick Quiz
1. In a Jupyter notebook, what keeps your variables in memory between cells?
The kernel is the Python process behind the notebook; it holds variables until it is restarted.
2. Which command adds pandas to a uv project?
uv add installs the package into the project environment and records it in pyproject.toml.
3. A script ends with the line sales.head() and prints nothing. Why?
Only notebooks show the last expression automatically. In a script, call print(sales.head()).
4. Why should you use a virtual environment for each project?
A virtual environment isolates packages, so upgrading pandas for one project does not break another.
Learn Data Science with a mentor
Free lessons get you started. Our Data Science & Machine Learning training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
