Python and Visual Studio Code Download & Installation
Python Download & Installation
Overview
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)
- Go to official website: Visit the official Python website https://www.python.org/downloads/
- Select version: Choose the latest stable version (e.g., 3.x).
- Choose installer: For Windows select Executable Installer, for macOS select pkg installer.
- Save file: Download and save the installer.
Installation (Windows)
- Run installer: Double-click the downloaded .exe file.
- Check “Add Python to PATH”: Enable this option.
This allows the
pythoncommand to run directly in Command Prompt. - Choose “Install Now”: Default settings are fine. You may use “Customize installation” if needed.
- Finish: After installation, enable “Disable path length limit” if prompted.
- Verify:
python --version pip --version
Installation (macOS)
- Run installer: Open the downloaded .pkg file and follow the steps.
- 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 - Verify:
python3 --version pip3 --version
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
python3 --version
pip3 --version
PIP & Virtual Environment
Use pip to install packages; use virtual environments to isolate project dependencies.
- Create venv:
python -m venv .venv # Windows python3 -m venv .venv # macOS/Linux - Activate venv:
.venv\Scripts\activate # Windows source .venv/bin/activate # macOS/Linux - Install packages:
pip install requests numpy - 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) orwhich python3(macOS/Linux). - PIP issues: Try
python -m pip --versionorpython -m ensurepip --upgrade.
Downloading & Installing Visual Studio Code for Python
Step 1: Download Visual Studio Code
- Go to official website: Visual Studio Code Downloads
- Select version: Choose the installer suitable for your operating system (Windows, Linux, macOS).
- Save installer: Download and save the installer on your computer.
Step 2: Install Visual Studio Code
- Run installer: Open the downloaded file (.exe for Windows, .dmg for macOS).
- Follow setup wizard: Default settings are usually fine. You may choose custom installation paths if needed.
- Finish installation: After installation, launch VS Code.
Step 3: Install Python Extension
- Open VS Code: Start the application.
- Go to Extensions: Click the Extensions icon (four squares) on the left sidebar.
- 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
- Check Python installation: In Terminal/Command Prompt run:
python --version pip --version - Run sample script: Create a new file in VS Code and add:
print("Welcome to Python World") - 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
- How do you check the latest installed Python version?
- What is the PATH variable?
- What does the command
pip install numpydo? - What is the command to create a virtual environment?
- Why is the Python extension required in VS Code?