Download Python Installer
First, you need to download the Python installer from the official Python website. Go to https://www.python.org/downloads/ and choose the version of Python you want to install. For beginners, it’s recommended to download the latest stable version.
Run the Installer
Once the installer is downloaded, locate the file and double-click on it to run it. You may need administrative privileges to install Python on your system.
Customize Installation (Optional)
During the installation process, you may be prompted to customize the installation. You can choose the installation directory, add Python to your system’s PATH, and select optional features. For most users, the default settings should be sufficient.
Start Installation
After customizing the installation settings (if needed), click on the “Install Now” button to start the installation process. The installer will copy the necessary files and configure Python on your system.
Verify Installation
Once the installation is complete, you can verify that Python has been installed successfully by opening a command prompt (on Windows) or a terminal (on macOS or Linux) and typing the following command:
python --version
This command will display the installed version of Python. If you see the version number, it means Python has been installed successfully.
Run a Python Script (Optional)
To test Python installation further, you can create and run a simple Python script. Open a text editor (such as Notepad on Windows or TextEdit on macOS) and create a new file with the following content:
print("Hello, Python!")
Save the file with a .py
extension, for example, hello.py
.
Open a command prompt or terminal, navigate to the directory where you saved the hello.py
file, and then run the following command:
python hello.py
You should see the output Hello, Python!
printed to the console, indicating that Python is working correctly.
You’ve successfully installed Python on your system. Now you’re ready to start writing and running Python code.