Python Installation
Before you can start coding in Python, you need to install it on your computer. Here are the steps to install Python:
Download Python:
- Visit the official Python website.
-
Navigate to the Downloads section, and click on the latest Python version for Windows. The installer file (e.g.,
python-<version>.exe
) will begin downloading.
Run the Installer:
- Locate the downloaded installer in your Downloads folder.
- Double-click the installer to launch the Python setup wizard.
Check "Add Python to PATH":
- On the first setup screen, check the box that says "Add Python to PATH" (very important to run Python from the command prompt).
- Click Install Now to begin the installation with the default settings.
Wait for Installation to Complete:
- The installation process will take a few moments. Once it's finished, you'll see a confirmation screen saying Setup was successful.
Verify Installation:
- Open the Command Prompt:
-
Press
Win + R
, typecmd
, and press Enter.
If Python is installed correctly, it will display the installed Python version (e.g., Python 3.x.x
).
Test Python:
- In the Command Prompt, type
- This will open the Python interactive shell.
- You can type simple commands like
Simple Python Program
- If you need an Integrated Development Environment (IDE), you can install IDLE (comes with Python), or use tools like VS Code, PyCharm, or Jupyter Notebook.
Follow these steps to install the latest version of Python on your Mac
Visit the Official Python Website
-
Go to the
Python website
- Click on the Downloads section.
- The website will automatically detect your operating system and show the latest Python version for macOS. Click Download Python <version>
-
Locate the downloaded
.pkg
file (e.g.,python-<version>.pkg
) in your Downloads folder. -
Double-click
.pkg
file to launch the installer.
- The installer will open with a welcome screen. click Continue.
- Review the license agreement, then click Agree to proceed.
- Select the installation location and click Install.
-
If prompted, enter your Mac`s administrator password to authorize the installation.
- Open the Terminal (you can search for it in Spotlight by passing cmd + Space and typing "Terminal").
- Type the following command to check if Python is installed and its version.
- you should see the installed version of Python.
On macOS, Python 3 is generally added to the PATH automatically. If you encounter issues, you may need to PATH manually.
- Open your terminal and type.
(Replace ~/.zshrc
with ~/.bash_profile
if you're using Bash shell instead of Zsh)
- Add the following line to include Python in your PATH
-
Save the file by pressing
ctrl + o
thenEnter ,
and exit withCtrl + X
. - Reload the shell configuration
Pip is Python's package manager and usually comes pre-installed with the latest Python. Verify it by typing
if pip isn't installed you can install it with.