Setting Up a Python-Ready DevOps Environment

Setting Up a Python-Ready DevOps Environment

Welcome back, folks! Here we are again, ready to cook up something exciting. If you caught the last blog, you already know why Python is our weapon of choice for this DevOps Voyage. Today, we’re stepping it up a notch—rolling up our sleeves to set up the ultimate Python-ready environment. From downloading and installing Python to getting VS Code locked and loaded, we’re making sure you’re ready to dive into Python like a true DevOps ninja. Let’s make it happen!


Step 1: Update and Upgrade System Packages

To ensure your system has the latest updates and dependencies, update your package manager.

  1. Open the terminal.

  2. Run the following commands:

     sudo apt update && sudo apt upgrade -y
    

Step 2: Install Python

  1. Check the Default Python Version

     python3 --version
    

    Ubuntu usually comes with a pre-installed Python version. If it's not the latest, proceed with installation.

    Follow these steps only if you want the latest version of Python (Optional).

  2. Add the Official Python PPA (if needed) To ensure you're getting the latest Python version:

     sudo add-apt-repository ppa:deadsnakes/ppa
     sudo apt update
    
  3. Install the Latest Python Version Replace <version> with the latest version number (e.g., 3.13.1):

     sudo apt install python3.<version> -y
    
  4. Verify the Installation

     python3 --version
    

Step 3: Install VS Code

  1. VIsti the official website of VS Code https://code.visualstudio.com/download:

  2. Download VS Code which is a .deb package and install VS Code:

  3. Install VS Code by using dpkg -i and Update your package manager:

     sudo apt update
     sudo apt install code -y
    
  4. Verify the Installation Open VS Code by typing:

     code
    


Step 4: Configure Python in VS Code

  1. Install the Python Extension

    • Open VS Code.

    • Press Ctrl+Shift+P to open the Command Palette.

    • Type Extensions: Install Extensions and hit Enter.

    • Search for Python by Microsoft and install it.


Step 5: Verify the Setup

  1. Create a Python File

    • Create a new folder for your project:

        mkdir Python && cd Python
      

    • Open the folder in VS Code:

        code .
      

    • Create a new file named hello.py with the following code:

        print("Welcome to DevOps Voyage !")
      
  2. Run the Python File

    • Open the integrated terminal in VS Code (Ctrl+ `).

    • Run the Python file:

        python3 hello.py
      
    • You should see:

        Welcome to DevOps Voyage !
      


Alright, I hope you’ve successfully set up your Python playground. Well done, and seriously, give yourself a high five! But hey, don’t get too comfy, because this was just the warm-up. The real game starts now. Oh yeah, you’re about to step into the shoes of a Developer—or dare I say—a Coder Extraordinaire. Feels kinda cool, right? 😏 So buckle up, because in our next blog, we’re diving headfirst into the Fundamentals of Python—the very foundation of all the magic we’re about to create. And, keep that enthusiasm alive!

Until next time, keep coding, automating, and advancing in DevOps! 😁

Peace out ✌️