Setting Up VS Code for Python
1. Install VS Code
Download and install VS Code from [Link]
2. Install Python
Download from [Link] and during installation, check 'Add Python to PATH'.
3. Install Python Extension in VS Code
Open VS Code > Extensions (Ctrl+Shift+X) > Search for 'Python' > Install the one by Microsoft.
4. Select Python Interpreter
Open Command Palette (Ctrl+Shift+P) > Type 'Python: Select Interpreter' > Choose Python 3.x or your virtual
environment.
5. Run Python Code
Create or open a .py file. Run it by:
- Right-click > 'Run Python File in Terminal'
- OR Ctrl+Alt+N (if Code Runner is installed)
- OR click the Run button.
6. Optional: Install Helpful Extensions
- Code Runner
- Pylance
- Jupyter (for notebooks)
Setting Up VS Code for Python
7. Optional: Set Up a Virtual Environment
In your project folder:
python -m venv venv
Activate with:
- Windows: venv\Scripts\activate
- Linux/Mac: source venv/bin/activate
8. Optional: Customize VS Code Settings
In File > Preferences > Settings:
- Enable linting
- Set formatter (e.g., 'black' or 'autopep8')