CodeSutraHub

Python and Visual Studio Code Download & Installation

Python Download & Installation

Overview

This section explains how to download and install Python.

Prerequisites

  • Internet connection: Required to download Python installer or packages.
  • Admin rights (Windows/macOS): May be required for system-wide installation.
  • Terminal/Command Prompt: Used to verify installation.

Download (Windows/macOS)

  1. Go to official website: Visit the official Python website https://www.python.org/downloads/
  2. Select version: Choose the latest stable version (e.g., 3.x).
  3. Choose installer: For Windows select Executable Installer, for macOS select pkg installer.
  4. Save file: Download and save the installer.
Tip: If you need Long-Term Support, choose a widely-used stable 3.x release.

Installation (Windows)

  1. Run installer: Double-click the downloaded .exe file.
  2. Check “Add Python to PATH”: Enable this option. This allows the python command to run directly in Command Prompt.
  3. Choose “Install Now”: Default settings are fine. You may use “Customize installation” if needed.
  4. Finish: After installation, enable “Disable path length limit” if prompted.
  5. Verify:
    
    python --version
    pip --version
    

Installation (macOS)

  1. Run installer: Open the downloaded .pkg file and follow the steps.
  2. PATH setup: Normally installer sets PATH automatically. If required in zsh:
    echo 'export PATH="/Library/Frameworks/Python.framework/Versions/3.x/bin:$PATH"' >> ~/.zprofile source ~/.zprofile
  3. Verify:
    
    python3 --version
    pip3 --version
    
Tip: On macOS, using python3 is recommended instead of python.

Installation (Linux)

On Linux, installation is easy using the package manager:

  • Debian/Ubuntu:
    
    sudo apt update
    sudo apt install python3 python3-pip
    
  • Fedora:
    
    sudo dnf install python3 python3-pip
    
  • Arch:
    
    sudo pacman -S python python-pip
    
Verify:

python3 --version
pip3 --version

PIP & Virtual Environment

Use pip to install packages; use virtual environments to isolate project dependencies.

  1. Create venv:
    
    python -m venv .venv        # Windows
    python3 -m venv .venv       # macOS/Linux
    
  2. Activate venv:
    
    .venv\Scripts\activate      # Windows
    source .venv/bin/activate   # macOS/Linux
    
  3. Install packages:
    pip install requests numpy
  4. Deactivate:
    deactivate

Hello World (Verification)

To verify installation, run this simple script:


# hello.py
print("Welcome to Python World")
  • Run (Windows): python hello.py
  • Run (macOS/Linux): python3 hello.py

Troubleshooting

  • Command not found: Check if PATH is set properly. On Windows, confirm “Add Python to PATH” was enabled.
  • Multiple versions: Use py -0 (Windows) or which python3 (macOS/Linux).
  • PIP issues: Try python -m pip --version or python -m ensurepip --upgrade.

Downloading & Installing Visual Studio Code for Python

Step 1: Download Visual Studio Code

  1. Go to official website: Visual Studio Code Downloads
  2. Select version: Choose the installer suitable for your operating system (Windows, Linux, macOS).
  3. Save installer: Download and save the installer on your computer.

Step 2: Install Visual Studio Code

  1. Run installer: Open the downloaded file (.exe for Windows, .dmg for macOS).
  2. Follow setup wizard: Default settings are usually fine. You may choose custom installation paths if needed.
  3. Finish installation: After installation, launch VS Code.

Step 3: Install Python Extension

  1. Open VS Code: Start the application.
  2. Go to Extensions: Click the Extensions icon (four squares) on the left sidebar.
  3. Search “Python”: Install the official Python extension provided by Microsoft.

Tip: The Python extension provides syntax highlighting, debugging, linting, and Jupyter Notebook support.

Step 4: Verify Python Setup

  1. Check Python installation: In Terminal/Command Prompt run:
    python --version
    pip --version
  2. Run sample script: Create a new file in VS Code and add:
    print("Welcome to Python World")
  3. Execute script: Right-click and choose the “Run Python File” option.

Troubleshooting

  • Python not found: Check whether the PATH variable is set correctly.
  • Extension issues: Reinstall the Python extension from the Extensions tab.
  • Multiple versions: Select the correct interpreter path in VS Code settings.

Frequently Asked Questions (FAQs)

1. What should I do if the Python command does not work after installation?

Ensure “Add Python to PATH” was enabled during installation. Otherwise, set the PATH variable manually.

2. Should I install Python 2 or Python 3?

Always install the latest stable version of Python 3. Python 2 is obsolete.

3. Can I learn Python without VS Code?

Yes. You can use Python IDLE. However, VS Code is recommended because it is a powerful editor.

4. What is pip?

pip is the Python package manager used to install external libraries.

5. Why is a Virtual Environment necessary?

It helps manage separate dependencies for each project and avoids version conflicts.

6. How do I verify Python installation?


python --version
pip --version

7. How to select Python interpreter in VS Code?

Press Ctrl + Shift + P → “Python: Select Interpreter” → Choose your installed version.

Practice Questions

  1. How do you check the latest installed Python version?
  2. What is the PATH variable?
  3. What does the command pip install numpy do?
  4. What is the command to create a virtual environment?
  5. Why is the Python extension required in VS Code?