How To Install Python 3 on CentOS 7
Enjoying this content? Subscribe to the Channel!
Python 3 for Beginners: Installation and Setting Up Your First Programming Environment
Introduction: Welcome to the World of Python!
Are you ready to dive into one of the most powerful and beginner-friendly programming languages on the planet? Python 3 is the engine driving everything from web development and data science to automation scripts, and getting started is easier than you think.
In this comprehensive guide, we’re walking through the exact steps Darren took in the video tutorial to get Python 3 installed, set up a clean local environment, and execute your very first Python script. No prior experience is needed—just enthusiasm!
We know technical commands can be tricky, so remember that you can find all the necessary commands used in this tutorial on Darren’s dedicated resource page: https://darrenoneill.eu/?p=317. And if you are working on a Linux machine, make sure you grab our free Linux cheat sheet right here: http://eepurl.com/dkRNM9.
Let’s get coding!
Step 1: Checking Your Current Python Installation
Before downloading anything new, it’s always a good practice to check if Python is already present on your system. Many operating systems (especially macOS and Linux distributions) come pre-installed with an older version of Python 2, or sometimes a recent version of Python 3.
Open your terminal (or Command Prompt/PowerShell on Windows) and type the following:
python3 --version
or
python --version
If you see a version number starting with 3.x.x (e.g., Python 3.10.4), you are likely good to go! If you see an error, or if the version starts with 2.x.x, we need to proceed with a fresh installation.
Step 2: Installing Python 3 (The Official Way)
To ensure we have the most stable and up-to-date version, we will always install Python from the official source.
For Windows and macOS Users:
- Navigate to the official Python website (python.org).
- Go to the “Downloads” section and select the installer appropriate for your operating system (Windows Installer or macOS installer).
- Crucial Step (Windows Only): When running the installer, make absolutely sure you check the box that says “Add Python to PATH” at the bottom of the first installation screen. This step is vital as it allows your operating system to find Python commands easily from any directory in the terminal.
- Follow the prompts and complete the installation.
For Linux Users:
Most modern Linux distributions come with Python 3 pre-installed. If you need to ensure you have the latest minor version, you can typically use your distribution’s package manager (e.g., apt, yum, or pacman).
For example, on Debian/Ubuntu systems, you would use:
sudo apt update
sudo apt install python3
Step 3: Verifying the Installation and PATH Setup
After installation, we need to confirm that the system correctly recognizes Python 3.
Open a new terminal window (this is important, as the PATH variable needs to refresh).
Run the version check again:
python3 --version
If you installed Python from the official site and checked the “Add to PATH” box (or if you are on macOS/Linux), this command should display your newly installed version. If this works, your core setup is complete!
Step 4: Setting Up Your Local Environment (Why venv Matters)
One of the best practices in modern Python development is using a virtual environment. A virtual environment (venv) creates an isolated space for each of your projects, ensuring that the dependencies (external libraries and packages) for one project do not conflict with another.
Let’s set up a new environment named my_first_project_env.
-
Create a Project Folder:
mkdir first_python_project cd first_python_project -
Create the Virtual Environment:
python3 -m venv my_first_project_env -
Activate the Environment:
- macOS / Linux:
source my_first_project_env/bin/activate - Windows (Command Prompt):
my_first_project_env\Scripts\activate - Windows (PowerShell):
.\my_first_project_env\Scripts\Activate.ps1
- macOS / Linux:
You will know the environment is active when you see the environment name (e.g., (my_first_project_env)) prepended to your command line prompt. Now, any packages you install are isolated to this project only!
Step 5: Creating Your First Python Program
It’s time to write the classic “Hello World” program! This confirms everything is set up correctly and executable.
-
Create a New File: Using your favorite text editor (like VS Code, Sublime Text, or even Notepad), create a new file named
hello.pyinside yourfirst_python_projectfolder. -
Add the Code: Paste the following single line of code into
hello.py:print("Hello, Darren's Tech Tutorials World!") -
Run the Program: Make sure your terminal is still in the
first_python_projectdirectory and your virtual environment is active. Execute the script using the Python interpreter:python hello.py
If everything worked perfectly, you should see the phrase “Hello, Darren’s Tech Tutorials World!” printed directly below your command. Congratulations—you just wrote and ran your first Python program!
Conclusion: What’s Next?
You’ve successfully navigated the installation process, mastered the crucial step of setting up a local virtual environment, and executed your first Python script. This foundational setup is the gateway to countless programming possibilities!
Now that you have the basic tools, you can start exploring tutorials on data structures, control flow, and external libraries.
If this guide helped you get up and running, please give the original video a huge thumbs up, subscribe to Darren’s Tech Tutorials for more clear and accessible guides, and let us know in the comments what you plan to build with Python first! Happy coding!