Installing Python & Setting Up Your Environment | Python Course – Lesson 2 | Dataplexa

Installing Python & Setting Up Your Environment

Before you can write and run Python programs, your computer needs to understand the Python language. This is done through a program called the Python interpreter — a piece of software that reads your code line by line and executes it immediately.

Installing Python means installing that interpreter on your system. Without it, your computer has no way to understand or run Python code, no matter how well you write it.

In this lesson, you will download Python 3, install it correctly, verify it works, and set up a professional development environment using Visual Studio Code.

Why Proper Python Installation Matters

Many beginners skip or rush through the installation process, which leads to problems that are difficult to diagnose later. A correct Python installation from the start ensures that:

  • Your system recognizes the python command in the terminal.
  • You can run Python scripts from any folder on your computer.
  • Your code editor can detect and use the correct Python version.
  • Libraries and packages install and work without conflicts.

Taking five extra minutes to install Python correctly saves hours of troubleshooting later.

Step 1: Download Python 3

Always download Python from the official Python website. Never install Python from third-party sources, as unofficial distributions may contain outdated versions or security risks.

Download Python from python.org →

  • Select the latest stable Python 3.x release for your operating system.
  • Avoid Python 2 — it reached end of life in 2020 and is no longer supported.
  • Python is available for Windows, macOS, and Linux.

Step 2: Install Python on Windows

When you run the Python installer on Windows, you will see an installation screen before anything is installed. There is one critical checkbox you must enable before proceeding:

☑ Add Python 3.x to PATH
This option allows Python to run from any folder in Command Prompt or Terminal.
  • Check this box before clicking "Install Now".
  • If you skip it, your system will not recognize the python command.
  • After enabling it, click Install Now and wait for the process to complete.

Installing Python on macOS

On macOS, download the .pkg installer from python.org and follow the installation wizard. macOS may already have Python 2 installed — make sure you install Python 3 separately and use the python3 command to run it.

Installing Python on Linux

Most Linux distributions come with Python 3 pre-installed. You can check this by running python3 --version in the terminal. If it is not installed, use your package manager:

# Ubuntu / Debian
sudo apt update
sudo apt install python3

# Fedora
sudo dnf install python3

Step 3: Verify the Python Installation

After installation, you must confirm that Python was installed correctly. Open your terminal — Command Prompt on Windows, Terminal on macOS and Linux — and type the following command:

python --version
Python 3.12.1

If you see a version number starting with 3, the installation was successful. On macOS or Linux, you may need to use python3 --version instead.

What to Do If You See an Error

If you see an error such as "python is not recognized as an internal or external command", it means PATH was not configured during installation. To fix this:

  • On Windows — uninstall Python, run the installer again, and make sure to check the Add Python to PATH option.
  • On macOS — use python3 instead of python in your terminal commands.
  • On Linux — confirm Python 3 is installed using which python3.

Understanding the Terminal and How Python Runs Files

The terminal is a text-based interface that lets you communicate directly with your operating system using commands. Professional developers use the terminal daily to run scripts, manage files, install libraries, and deploy applications.

When you run a Python file from the terminal, the command structure looks like this:

python test.py
The Python interpreter reads test.py from top to bottom and executes each instruction.
  • python — calls the Python interpreter installed on your system.
  • test.py — the filename of the Python script you want to run.
  • The interpreter reads your code from the first line to the last and executes each instruction in order.

Step 4: Install Visual Studio Code

You can write Python code in any plain text editor, but a professional code editor makes development significantly faster and less error-prone. At Dataplexa, we recommend Visual Studio Code (VS Code) — a free, open-source editor built by Microsoft that is widely used in industry.

Download VS Code from code.visualstudio.com →

Setting Up the Python Extension in VS Code

After installing VS Code, you need to add the official Python extension to enable Python-specific features:

  • Open VS Code.
  • Click the Extensions icon in the left sidebar (or press Ctrl+Shift+X).
  • Search for Python in the search bar.
  • Click Install on the extension published by Microsoft.

The Python extension gives you:

  • Syntax highlighting — Color-coded code that is easier to read and debug.
  • IntelliSense — Auto-complete suggestions as you type.
  • Linting — Real-time error detection before you run the code.
  • Integrated debugger — Step through your code line by line to find issues.
  • Integrated terminal — Run Python directly inside VS Code without switching windows.

Step 5: Write and Run Your First Python File

Now that Python and VS Code are installed, let us create and run your first real Python file. This confirms that your entire development environment is working correctly end to end.

Create a new file named test.py and write the following code:

print("Python is installed successfully!")
Python is installed successfully!

Now open the terminal inside the folder where you saved test.py and run:

python test.py
Python is installed successfully!

What Just Happened?

  • You created a Python source file named test.py.
  • The Python interpreter read the file and found the print() instruction.
  • It executed that instruction and displayed the message on the screen.
  • Your development environment is now fully functional and ready for the course.

Other Python Editors Worth Knowing

While VS Code is our primary recommendation, other editors and environments are commonly used in the Python community:

  • PyCharm — A dedicated Python IDE with powerful refactoring and debugging tools. The Community edition is free.
  • Jupyter Notebook — An interactive notebook environment used heavily in data science and machine learning.
  • Google Colab — A free cloud-based Jupyter environment that runs in your browser with no installation required.
  • Thonny — A beginner-friendly IDE designed specifically for learning Python, with a built-in debugger.
  • Sublime Text — A lightweight and fast text editor with Python support through plugins.

Common Python Installation Issues and How to Fix Them

These are the most frequently encountered problems during Python setup and their solutions:

  • "Python is not recognized" — PATH was not added during installation. Reinstall Python and check the PATH option.
  • VS Code not detecting Python — Install the Microsoft Python extension and select the correct interpreter using Ctrl+Shift+P → "Python: Select Interpreter".
  • Multiple Python versions installed — Use python3 on macOS and Linux to ensure you are running Python 3 specifically.
  • pip not working — Run python -m pip install --upgrade pip to update the package installer.
  • Permission errors on Mac/Linux — Use sudo before the installation command or use a virtual environment.

What Is pip and Why Does It Matter?

When Python is installed, it also installs a tool called pip — Python's package manager. pip allows you to install third-party libraries from the Python Package Index (PyPI) with a single command.

You can verify pip is installed by running:

pip --version
pip 23.3.1 from /usr/local/lib/python3.12/site-packages/pip (python 3.12)

Throughout this course, you will use pip to install libraries like NumPy, Pandas, and scikit-learn. Understanding pip from the beginning sets you up for success in every future lesson.

Frequently Asked Questions

Which Python version should I install?

Always install the latest stable Python 3 release. As of 2025, Python 3.12 is the recommended version. Avoid Python 2 entirely — it is no longer maintained.

Do I need to pay for VS Code?

No. Visual Studio Code is completely free and open source. The Python extension is also free. You will never need to pay to use any tool recommended in this course.

Can I use a different editor instead of VS Code?

Yes. Any plain text editor can run Python. However, VS Code provides features that significantly speed up your development — especially as your programs become more complex. We recommend starting with VS Code.

What is the difference between Python and pip?

Python is the programming language interpreter. pip is Python's package manager — a tool that allows you to install additional libraries that extend Python's functionality. Both are installed together when you download Python from python.org.

Practice

What is the name of the program that reads and executes Python code line by line?



Quick Quiz

Which installation setting allows Python to run from any folder in the terminal?





What is the name of Python's package manager used to install third-party libraries?





NEXT UP
Variables in Python
Learn how to create variables, assign values, update them, and use them to store and reuse data across your Python programs.