Codeskill

Learn to code, step by step

Python Basics: Setting Up Your Development Environment

We’ll walk through setting up a Python development environment on Windows, Mac, or Linux. By the end you will have Python installed, an editor ready, and a working virtual environment.

Why a good development environment matters

You need the Python interpreter, a decent code editor, and a sensible place to install packages. Get those three things sorted and the rest of learning Python is much less fiddly.

Step 1: Installing Python

Download the latest version from the official Python website. On Windows, tick "Add Python to PATH" during installation – it saves hassle later when you want to run Python from the command line.

Mac and Linux often ship with Python already installed. Check by opening a terminal and running python --version. If you need a different version, grab it from python.org or use a package manager like Homebrew on Mac.

Step 2: Choosing a code editor

Any text editor will do, but one built for coding is worth it. I use Visual Studio Code (VS Code) – free, lightweight, and it handles Python well. PyCharm suits larger projects. Sublime Text is another option.

Install the Python extension for your editor. In VS Code, find it in the Extensions marketplace. You get syntax highlighting, code completion, and debugging tools.

Step 3: Setting up a virtual environment

A virtual environment keeps each project’s packages separate. Handy when two projects need different versions of the same library. Navigate to your project folder in the terminal and run:

python -m venv myenv

That creates a myenv folder with its own Python copy and a place for packages. To activate it:

  • On Windows: myenv\Scripts\activate
  • On Mac/Linux: source myenv/bin/activate

Once activated, install packages with pip without touching your system-wide Python.

Step 4: Hello world and running your first script

Create a file called hello.py in your editor:

print("Hello, Python world!")

Save it, open a terminal in that folder, and run:

python hello.py

You should see Hello, Python world! on screen. That is your first Python script running.

Step 5: Exploring further

As you get more comfortable, you might want a full IDE like PyCharm – better debugging, smarter autocomplete, and project management built in. Not essential to start with, but useful later.

A few practical tips

  1. Stay organised: keep project files in sensible folders. You will thank yourself when a project grows.
  2. Experiment with libraries: Python has thousands of them. Try things out – that is how you learn what is available.
  3. Version control: learn Git, even for solo projects. It tracks what you changed and when.

Your development environment is your workspace. Set it up once, tweak it as you go, and you are ready for the tutorials ahead.

PreviousAn introduction to Python