How to Install Python, Jupyter Notebook and VS Code for Data Science (Windows and Mac)
P1.3 How to Install and Open Jupyter Notebook
In short: Jupyter lets you run code in small pieces and see each result right away.
Why. Jupyter lets you run code in small pieces and see each result right away. This is perfect for data work, where you look at data, change one thing and look again.
What. Jupyter Notebook is installed with pip, the Python package installer. A notebook is a file ending in .ipynb. It holds code cells, their outputs and text notes.
- Cell — one box of code or text.
- Shift+Enter — run the cell and move to the next one.
- Kernel — the Python engine behind the notebook.
How.
Install and start Jupyter
- Open Command Prompt (Windows) or Terminal (Mac).
- Type
pip install notebook(Mac:pip3 install notebook) and press Enter. - Wait until it says "Successfully installed".
- Type
jupyter notebookand press Enter. - Your browser opens a page with your folders.
- Click New → Python 3 to create a notebook.
Worked example A — Install Jupyter.
Step 1 — What we do. We install the notebook package.
Step 2 — Type and run this code.
pip install notebook
Step 3 — Output you should see.
Successfully installed notebook-7.2.1 ...
Step 4 — What it means. pip downloads Jupyter and everything it needs. You only do this once per computer (or once per virtual environment, see the modules chapter).
Worked example B — Your first notebook cell.
Step 1 — What we do. In a new notebook, type this in the first cell and press Shift+Enter. A hospital in Mumbai has 120 beds and 87 are filled.
Step 2 — Type and run this code.
beds = 120
filled = 87
print("Free beds:", beds - filled)
Step 3 — Output you should see.
Free beds: 33
Step 4 — What it means. The result appears right under the cell. You can change 87 to 95 and press Shift+Enter again to see the new answer at once. That fast loop is why analysts love Jupyter.
Worked example C — The last line shows itself.
Step 1 — What we do. In Jupyter, the value on the last line of a cell is shown even without print. Type only this in a new cell:
Step 2 — Type and run this code.
120 - 87
Step 3 — Output you should see.
33
Step 4 — What it means. Jupyter shows 33 because it is the last line. In a normal .py script, nothing would show without print. Use print when you are not sure.
Ravindra Bagale's Tip
Start Jupyter from the folder where your data files are. Then pandas can find your CSV files by name, with no long paths.
Ravindra Bagale's Tip – मराठी
तुमच्या data files ज्या folder मध्ये आहेत तिथून Jupyter सुरू करा. मग pandas ला CSV files फक्त नावाने सापडतील, लांब path ची गरज नाही.
Ravindra Bagale's Tip – हिंदी
जिस folder में आपकी data files हैं वहीं से Jupyter शुरू करो. फिर pandas को CSV files सिर्फ नाम से मिल जाएँगी, लंबे path की ज़रूरत नहीं.