How to install Python on Fedora 43

Cover Image

Getting Started with Python on Fedora 43: A Beginner's Guide

Hey there, fellow coders! Just got your shiny new Fedora 43 system up and running and ready to dive into some Python programming? Excellent choice! Python is a fantastic language for beginners and pros alike, thanks to its readability and massive ecosystem. This guide will walk you through installing Python on Fedora 43, ensuring you have everything you need to get started. Let's get those snake-charming skills honed!

Checking if Python is Already Installed

First things first, let's check if Python is already chilling on your system. Fedora often comes with Python pre-installed. Open your terminal (you can usually find it by searching for "Terminal" in your applications) and type the following command:

python3 --version

If you see output similar to "Python 3.x.x" (where 'x' represents version numbers), congratulations! Python is already installed. You can skip to the next sections on virtual environments. If you get an error saying "command not found" or something similar, then it's time to install.

Installing Python 3

If Python isn't pre-installed, don't worry, it's super easy to install using Fedora's package manager, DNF. Just type the following command into your terminal and press Enter:

sudo dnf install python3

You might be prompted for your password. Enter it and then type "y" (for yes) when asked if you want to proceed with the installation. DNF will then download and install Python 3 and any required dependencies. This is the recommended way to install Python, as it ensures the installation is managed by your system's package manager.

Verifying the Installation

After the installation completes, verify that Python is installed correctly by running the version check again:

python3 --version

You should now see the Python 3 version number. Awesome! You're now ready to write some Python code.

Setting up a Virtual Environment (Highly Recommended!)

Okay, you've got Python installed. Great! But before you start writing serious code, let's talk about virtual environments. Think of them as isolated sandboxes for your Python projects. They allow you to install packages specific to a project without messing with the global Python installation or causing conflicts with other projects. Trust me, using virtual environments will save you headaches down the road. Here's how to create one:

  1. First, make sure you have the venv module installed. It's usually part of the Python installation, but if not, you can install it with:

    sudo dnf install python3-venv
  2. Navigate to the directory where you want to store your project using the cd command. For example:

    cd ~/my-python-project
  3. Create the virtual environment. Let's call it "myenv" but you can name it whatever you like:

    python3 -m venv myenv
  4. Activate the virtual environment. This tells your terminal to use the Python installation within the environment:

    source myenv/bin/activate

    You'll notice that your terminal prompt changes to show the name of your environment (e.g., (myenv) $). This indicates that the environment is active.

Now, when you use pip (Python's package installer) to install packages, they'll be installed only within this virtual environment. To deactivate the environment when you're done working on the project, just type:

deactivate

Installing Packages with pip

With Python and a virtual environment ready, it's time to install some packages using pip. Let's say you want to install the popular "requests" library for making HTTP requests. Make sure your virtual environment is activated and then type:

pip install requests

Pip will download and install the package and all its dependencies. That's it! Now you can import and use the "requests" library in your Python code.

Wrapping Up

Congratulations! You've successfully installed Python on Fedora 43 and set up a virtual environment. You're now ready to start coding! Explore the vast world of Python libraries and frameworks, and have fun creating awesome projects. Happy coding!