Introduction
Python is a widely used programming language known for its simplicity and versatility. This guide will walk you through the installation and setup process for Python on different operating systems.
Step 1: Download Python
- Visit the official Python website: https://www.python.org/downloads/
- The website will automatically suggest the latest version for your operating system.
- Click the Download Python button to get the installer.
Step 2: Install Python
Windows
- Run the downloaded
.exe
file. - Check the box “Add Python to PATH” to make Python accessible from the command line.
- Click Install Now and wait for the installation to complete.
- Verify installation by opening Command Prompt and typing:
python --version
macOS
- Open the downloaded
.pkg
file and follow the installation instructions. - To verify the installation, open the Terminal and run:
python3 --version
- If Python 3 is not recognized, add it to your PATH manually.
Linux (Ubuntu/Debian)
Python is usually pre-installed on Linux. To check the installed version, run:
python3 --version
If Python is not installed, use the following commands:
sudo apt update
sudo apt install python3
Step 3: Install a Code Editor (Optional)
To write and run Python scripts efficiently, install a code editor:
- VS Code: https://code.visualstudio.com/
- PyCharm: https://www.jetbrains.com/pycharm/
- Jupyter Notebook (for data science):
pip install notebook jupyter notebook
Step 4: Install Python Packages
Python uses pip (Python Package Installer) to install external libraries.
- Verify pip installation:
pip --version
- Install a package, e.g., NumPy:
pip install numpy
Step 5: Run a Test Script
- Open a text editor and create a new file named
test.py
. - Write the following Python code:
print("Hello, Python!")
- Save the file and run it in the terminal:
python test.py
You have successfully installed and set up Python on your system! You can now start coding, install additional libraries, and explore Python’s capabilities.