fervor [>]CODING & CURIOSITY
FERVOR LEARNING SYSTEMTUTORIALS
← Python

Python / 6 MIN READ

Python Installing

Installing Python and setting up your environment

From the original Fervor library. Examples may use older package versions.

How to Install Python: A Friendly Step-by-Step Guide

So you want to dive into the world of Python? Excellent choice! It’s like having a Swiss Army knife for coding—simple, versatile, and powerful. Let’s get Python set up on your computer so you can start automating tasks, building cool projects, or just impressing your friends.


Step 1: Check if Python is Already Installed

Why?

Many systems come with Python pre-installed, especially macOS and Linux.

How?

  1. Open a terminal:
    • Windows: Open the Command Prompt by typing cmd in the search bar.
    • macOS/Linux: Use Spotlight (Cmd + Space) or your terminal app.
  2. Type:
    python --version
    
    or:
    python3 --version
    

What Happens?

  • If you see something like Python 3.x.x, congrats—you already have it!
  • If you see an error or a version less than 3.7, you’ll need to install or update Python.

Step 2: Download Python

Where?

Head over to python.org.

  1. Click the Downloads tab (the website usually highlights the best version for your system).
  2. Download the installer for your operating system:
    • Windows: Windows Installer
    • macOS: macOS Installer
    • Linux: You may need to use your package manager (more on that below).

Step 3: Install Python

For Windows Users

  1. Open the downloaded .exe file.
  2. Before you click Install Now, check the box that says:
    Add Python 3.x to PATH
    
    (This is super important—it makes Python accessible from the command line.)
  3. Click Install Now.
  4. Wait for the installation to finish, and click Close.

For macOS Users

  1. Open the downloaded .pkg file.
  2. Follow the on-screen instructions.
  3. After installation, verify it:
    • Open Terminal and type:
      python3 --version
      

For Linux Users

  1. Open your terminal.
  2. Use your package manager to install Python:
    • Debian/Ubuntu:
      sudo apt update
      sudo apt install python3
      
    • Fedora:
      sudo dnf install python3
      
  3. Verify installation:
    python3 --version
    

Step 4: Install a Text Editor or IDE

You’ll need a place to write your Python code. Here are some popular choices:

  1. VS Code (Recommended)
  2. PyCharm (Feature-rich but heavier)
  3. IDLE (Comes with Python, lightweight).

Step 5: Test Your Installation

Why?

Make sure everything’s working before diving into coding.

How?

  1. Open your terminal or command prompt.
  2. Type:
    python3
    
    or:
    python
    
  3. You should see something like:
    Python 3.x.x (some build info)
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    
  4. Type your first Python command:
    print("Hello, Python!")
    
  5. If it prints Hello, Python!, you’re good to go. 🎉

Step 6: Install Pip (Optional)

What is Pip?

It’s Python’s package manager, like an app store for libraries and tools.

How?

  1. Pip often comes pre-installed with Python 3. Ensure it’s there:
    pip --version
    
  2. If it’s missing, you can install it:
    python3 -m ensurepip --upgrade
    

You’re All Set!

You now have Python installed and ready to use. Whether you’re writing a script, automating tasks, or building the next big thing, Python is ready to be your trusty companion.

Next Steps:

  1. Learn the basics: variables, loops, functions.
  2. Try small projects, like a calculator or a guessing game.
  3. Explore libraries like requests (for web stuff) and pandas (for data).

Happy coding, and remember: The only bugs you want are the ones you debug. 🐛

Bonus Trouble Shooting on Mac

Tutorial: Fixing “command not found” for Python on Mac (Using python3)

So, you’re on a Mac and running into the dreaded "command not found" issue when you try to run python. Don’t worry; Macs sometimes like to play hard to get with Python. Here’s how you can fix it step by step, including installing Python 3 using Homebrew.


Step 1: Check for Python 3 Installation

Before jumping into installation, let’s check if Python 3 is already on your Mac. Open your Terminal (press Cmd + Space, type Terminal, and hit Enter) and run:

python3 --version

What Happens:

  1. If you see something like Python 3.x.x: 🎉 Python 3 is installed! Skip to Step 5.
  2. If you see command not found: No worries, let’s install Python 3.

Step 2: Install Homebrew (If Not Already Installed)

Homebrew is like a magical package manager for macOS. If you don’t already have it installed:

  1. Open your Terminal.
  2. Run this command to install Homebrew:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  3. Follow the on-screen instructions. Homebrew may ask for your password—type it in and hit Enter (it won’t show as you type, but that’s normal).

Verify Homebrew Installation:

Once the installation is complete, verify it with:

brew --version

You should see a version number like Homebrew 4.x.x.


Step 3: Install Python 3 Using Homebrew

Now that Homebrew is ready, install Python 3 with:

brew install python3

What Happens:

  • Homebrew downloads and installs the latest version of Python 3.
  • It also sets up pip3 (Python’s package manager) for you.

Step 4: Verify Python 3 Installation

After installation, check if Python 3 is correctly installed:

python3 --version

You should see something like Python 3.x.x. If so, Python 3 is good to go! 🎉


Step 5: Running Python Scripts

Let’s say you have a script called clean_vt.py that you want to run. Use python3 to execute it:

  1. Navigate to the folder where your script is stored. For example:
    cd path/to/your/script
    
  2. Run the script:
    python3 clean_vt.py
    

If your script runs without errors, you’re all set!


Step 6: (Optional) Create an Alias for Easier Use

Tired of typing python3 all the time? You can create an alias to make life easier.

  1. Open your Terminal and edit your shell configuration file:
    • For zsh (default on newer Macs):
      nano ~/.zshrc
      
    • For bash (older Macs):
      nano ~/.bash_profile
      
  2. Add this line at the bottom of the file:
    alias python="python3"
    
  3. Save and exit (press Ctrl+O, then Enter, then Ctrl+X).
  4. Apply the changes:
    source ~/.zshrc
    
    or:
    source ~/.bash_profile
    

Now you can simply type python to run Python 3!


Step 7: Install Additional Tools (Optional)

Pip (Python Package Manager)

pip usually comes with Python 3, but if you want to ensure it’s up to date:

python3 -m ensurepip --upgrade

Install popular libraries like requests or numpy:

pip3 install requests numpy

Troubleshooting

  1. Command Not Found After Installation:
    Make sure Homebrew’s binaries are in your PATH. Add this to your ~/.zshrc or ~/.bash_profile:

    export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
    

    Then run:

    source ~/.zshrc
    
  2. Still Having Issues?
    Let me know what you’re seeing, and I’ll help you debug!


Now you’re all set to conquer Python on your Mac! 🎉 Time to put that clean_vt.py script to work or start building your next big project. 🚀

Keep your curiosity going.Explore more Python →
287 TUTORIALS · 22 TOPICSREADY