Python Setup Manual for Students
Windows & macOS · Multiple Python versions · Virtual environments · Jupyter in VS Code
By the end of this manual you will be able to:
- Install one or more Python versions and switch between them
- Create a separate virtual environment for each project
- Write and run Jupyter notebooks inside Visual Studio Code
We use uv, a free, fast tool that installs Python versions and manages virtual environments with the same commands on Windows and macOS. You do not need to install Python from python.org or Anaconda first.
⏱️ Time needed: about 20–30 minutes. You need an internet connection and permission to install software on your computer.
Table of Contents
- Key ideas in 2 minutes
- Open a terminal
- Install uv
- Install and switch Python versions
- Create a project and a virtual environment
- Install packages
- Install and set up VS Code
- Run a Jupyter notebook in VS Code
- Daily workflow cheat sheet
- Troubleshooting
- Final checklist
1. Key ideas in 2 minutes
| Term | What it means |
|---|---|
| Python version | Python exists in versions such as 3.11, 3.12 and 3.13. Some courses or libraries need a specific one, so it is useful to have several installed. |
| Virtual environment (venv) | A private folder (usually called .venv) inside your project that holds one Python version plus the packages for that project only. Projects don't interfere with each other. |
| Package | Extra code you install, such as numpy, pandas or matplotlib. |
| uv | The tool that downloads Python versions, creates virtual environments and installs packages. |
| Jupyter notebook | A .ipynb file with cells of code, output and text. VS Code can open and run them. |
| Kernel | The Python that actually runs your notebook's code. You will point it at your project's .venv. |
Golden rule: one project folder → one virtual environment → one set of packages.
2. Open a terminal
All commands in this manual are typed in a terminal.
Windows Press the Windows key, type PowerShell, and open Windows PowerShell (or Terminal). Do not choose "Run as administrator"; it isn't needed.
macOS
Press Cmd + Space, type Terminal, and press Enter.
💡 In this manual, lines in grey boxes are commands. Type (or paste) them and press Enter. Don't type the
#comments.
3. Install uv
Windows (PowerShell)
1 | |
Alternative if you use winget: winget install --id=astral-sh.uv -e
macOS (Terminal)
1 | |
Alternative if you use Homebrew: brew install uv
Check that it worked
Close the terminal and open a new one (so it picks up the new program), then run:
1 | |
You should see something like uv 0.x.y. If you get "command not found" / "not recognized", see Troubleshooting.
4. Install and switch Python versions
Install one or more versions
1 | |
This downloads both versions. They live in uv's own folder and won't conflict with any Python that is already on your computer.
See what is available and installed
1 | |
Installed versions show a file path; versions that can be downloaded are marked as such.
Switching versions — the idea
With uv you don't "switch" your whole computer from one Python to another. Instead, each project chooses its version. There are three ways to do this:
| Situation | Command |
|---|---|
| Run a quick one-off with a specific version | uv run --python 3.13 python --version |
| Make a project always use a version | uv python pin 3.12 (run inside the project folder; creates a .python-version file) |
| Create a virtual environment with a version | uv venv --python 3.12 (see section 5) |
Try it:
1 2 | |
You should see two different version numbers. 🎉 You now have multiple Python versions.
Removing a version (optional)
1 | |
5. Create a project and a virtual environment
5.1 Make a project folder
Windows (PowerShell)
1 2 | |
macOS
1 2 | |
⚠️ Avoid putting projects in OneDrive/iCloud-synced folders if you can; syncing thousands of small files in
.venvcan cause errors and slowness.
5.2 Create the virtual environment
1 2 | |
uv venv creates a .venv folder using the pinned version. You could also skip the pin and write uv venv --python 3.12.
5.3 Activate the environment
Activating means "from now on, python in this terminal refers to this project's .venv".
Windows (PowerShell)
1 | |
macOS
1 | |
Your prompt now starts with (python-course) or (.venv). Check:
1 | |
It should show 3.12.x.
To leave the environment:
1 | |
🔁 You must activate the environment each time you open a new terminal for this project. (VS Code can do this automatically; see section 7.)
5.4 Changing the Python version of a project
A virtual environment is tied to one Python version. To change it, simply rebuild it:
1 2 3 | |
Then reinstall your packages (easy if you keep a requirements.txt, see next section).
6. Install packages
With the environment activated, install packages with uv pip:
1 | |
✅
ipykernelis required for Jupyter notebooks in VS Code. Always install it in every environment you want to use for notebooks.
Useful commands:
| Task | Command |
|---|---|
| List installed packages | uv pip list |
| Save your package list | uv pip freeze > requirements.txt |
| Install from a list (e.g. from your teacher) | uv pip install -r requirements.txt |
| Remove a package | uv pip uninstall pandas |
💡 Tip for later: uv also has a "project" workflow (
uv init,uv add numpy,uv sync) that records packages automatically in apyproject.tomlfile. It's great once you're comfortable, but the commands above are all you need for this course.
7. Install and set up VS Code
7.1 Install VS Code
Download it from https://code.visualstudio.com and run the installer.
- Windows: in the installer, tick "Add to PATH" and "Add 'Open with Code' action".
- macOS: drag Visual Studio Code into your Applications folder. Then open VS Code, press
Cmd + Shift + P, type Shell Command: Install 'code' command in PATH and press Enter.
7.2 Install the extensions
- Open VS Code.
- Click the Extensions icon in the left sidebar (four squares), or press
Ctrl + Shift + X(Windows) /Cmd + Shift + X(Mac). - Search for and install:
- Python (publisher: Microsoft)
- Jupyter (publisher: Microsoft)
The Python extension also installs Pylance and a Python Environments helper automatically.
7.3 Open your project folder
In the terminal, inside your project folder:
1 | |
Or use File → Open Folder… and choose python-course. If VS Code asks whether you trust the authors of the folder, click Yes.
⚠️ Always open the project folder, not a single file. VS Code finds
.venvby looking in the open folder.
7.4 Select the interpreter
- Press
Ctrl + Shift + P(Windows) /Cmd + Shift + P(Mac). - Type Python: Select Interpreter and press Enter.
- Choose the entry that shows
.venv(e.g.Python 3.12.x ('.venv': venv)).
Now open a new terminal in VS Code (Terminal → New Terminal). It should activate .venv automatically; you'll see (.venv) or the project name in the prompt.
7.5 Quick test with a script
Create a file hello.py:
1 2 3 | |
Click the ▶️ Run button in the top-right. The output should show your chosen version and a path that contains .venv.
8. Run a Jupyter notebook in VS Code
- Press
Ctrl/Cmd + Shift + P→ Create: New Jupyter Notebook (or create a file ending in.ipynb, e.g.week1.ipynb). - Click Select Kernel in the top-right of the notebook.
- Choose Python Environments… → select the
.venvof your project. - In the first cell type:
1 2 | |
- Press
Shift + Enterto run the cell.
The output path should contain .venv. Try a second cell:
1 2 3 4 5 6 7 | |
You should see a sine wave. 🎉
If VS Code shows a popup saying "Running cells requires the ipykernel package", click Install, or run
uv pip install ipykernelin the activated environment and then choose the kernel again.
Useful notebook shortcuts
| Action | Shortcut |
|---|---|
| Run cell and move to next | Shift + Enter |
| Run cell and stay | Ctrl + Enter (Win) / Cmd + Enter (Mac) |
| New cell below | B (when not typing in a cell; press Esc first) |
| Delete cell | D D (press twice, when not typing) |
| Change to Markdown cell | M |
| Change to code cell | Y |
| Restart kernel | Click Restart in the notebook toolbar |
9. Daily workflow cheat sheet
Starting a new project
1 2 3 4 5 6 7 8 | |
Then in VS Code: Select Interpreter → .venv and in notebooks Select Kernel → .venv.
Continuing an existing project
1 2 | |
VS Code remembers the interpreter and kernel.
Getting a project from a teacher or classmate
1 2 3 4 | |
🚫 Never copy or share the
.venvfolder itself (e.g. by email or USB). It's large and only works on the computer that created it. Sharerequirements.txtinstead. If you use Git, add.venv/to your.gitignore.
10. Troubleshooting
uv is "not recognized" / "command not found"
Close all terminals (and VS Code) and open a new one. The installer changed your PATH, and only new windows see it. On macOS you can also run source ~/.zshrc. If that doesn't help, rerun the install command from section 3.
Windows: "running scripts is disabled on this system" when activating PowerShell blocks scripts by default. Run this once (not as administrator):
1 | |
Answer Y, then try activating again.
Windows: typing python opens the Microsoft Store
That's a Windows shortcut, not real Python. Either activate your .venv first, or turn it off: Settings → Apps → Advanced app settings → App execution aliases → switch off python.exe and python3.exe.
macOS: a popup asks to install "command line developer tools" Click Install. This is Apple's standard developer package; it's safe and sometimes needed.
VS Code doesn't show my .venv in the list
- Make sure you opened the project folder (File → Open Folder).
- Choose Enter interpreter path… and browse to:
- Windows: .venv\Scripts\python.exe
- macOS: .venv/bin/python
- Reload VS Code: Ctrl/Cmd + Shift + P → Developer: Reload Window.
ModuleNotFoundError: No module named 'numpy' in a notebook
The notebook is using a different kernel than the environment where you installed the package. Check the kernel name in the top-right; select your .venv. Then run import sys; print(sys.executable) to confirm.
I installed a package but my notebook still can't find it Restart the kernel (toolbar → Restart) after installing packages.
Something is completely broken
A virtual environment is disposable. Delete the .venv folder and recreate it:
1 2 3 | |
11. Final checklist
Tick each item when it works:
-
uv --versionprints a version number -
uv python listshows at least two installed Python versions -
uv run --python 3.12 python --versionand... 3.13 ...print different versions - I created a project folder with a
.venvinside it - After activating,
python --versionshows the expected version -
uv pip listshowsipykernel,numpy,pandasandmatplotlib - VS Code has the Python and Jupyter extensions installed
- VS Code's selected interpreter is my project's
.venv - A notebook runs a cell and
sys.executablepoints into.venv - The sine-wave plot appears in my notebook
All ticked? You're ready for the course. 🚀
Further reading: uv documentation: https://docs.astral.sh/uv/ · VS Code Python docs: https://code.visualstudio.com/docs/python/python-tutorial · VS Code Jupyter docs: https://code.visualstudio.com/docs/datascience/jupyter-notebooks