How to Install Python, Jupyter Notebook and VS Code for Data Science (Windows and Mac)
P1.4 How to Set Up VS Code for Python
Why. Notebooks are great for exploring. For longer scripts, projects and Git, a code editor is easier. VS Code is free and also opens .ipynb notebooks.
What. VS Code is an editor from Microsoft. The Python extension adds running, error checking and notebook support.
How.
Set up VS Code
- Download VS Code from code.visualstudio.com and install it.
- Open VS Code.
- Click the Extensions icon on the left (four squares).
- Search Python and install the one by Microsoft.
- Press Ctrl+Shift+P (Mac: Cmd+Shift+P), type Python: Select Interpreter and pick your Python 3.
- Create a file named
hello.py. - Click the ▶ Run button at the top right.
Worked example A — A small script file.
Step 1 — What we do. Save this as hello.py in VS Code and click Run. A logistics team in Singapore checks parcels.
Step 2 — Type and run this code.
parcels = 250
delivered = 238
print("Pending parcels:", parcels - delivered)
Step 3 — Output you should see.
Pending parcels: 12
Step 4 — What it means. VS Code runs the whole file from top to bottom and shows the result in the Terminal panel at the bottom.
Worked example B — Run the same script from the terminal.
Step 1 — What we do. Open the terminal in the folder of hello.py and run it.
Step 2 — Type and run this code.
python hello.py
Step 3 — Output you should see.
Pending parcels: 12
Step 4 — What it means. This is exactly what the Run button does for you. On Mac type python3 hello.py.
| Tool | Best for | File type |
|---|---|---|
| Jupyter Notebook | Exploring data step by step, charts | .ipynb |
| VS Code | Scripts, projects, Git | .py and .ipynb |
| Terminal | Installing packages, quick runs | — |
How to read this table: each row is one tool. The columns say what it is best for and which files it uses.
Ravindra Bagale's Tip
Use Jupyter to explore and VS Code to keep the final clean script. Many analysts do both every day.
Ravindra Bagale's Tip – मराठी
Explore करायला Jupyter आणि final स्वच्छ script ठेवायला VS Code वापरा. बरेच analysts रोज दोन्ही वापरतात.
Ravindra Bagale's Tip – हिंदी
Explore करने के लिए Jupyter और final साफ़ script रखने के लिए VS Code इस्तेमाल करो. बहुत से analysts रोज़ दोनों इस्तेमाल करते हैं.