How to set up a python programming workspace

An editor, a terminal, and a folder that belongs to this project: that is the whole workspace, and it can be running in fifteen minutes. Most setup advice buries that small truth under a dozen tools because the author is describing the machine they wish they had at the start. Here is the order that avoids rework, written for someone who has never installed a language before.

Install one interpreter and confirm where it lives

Download Python from the official site for your operating system, and on Windows tick the box that adds it to your PATH during the installer. Then open a terminal and run python --version (or python3 --version on macOS and Linux). A version number coming back means the command on your system is wired to a real interpreter.

Run which python3 or, on Windows, where python. Note the path. When something later behaves strangely — two Pythons fighting over packages — this is the first thing you will check, and knowing it now saves an hour of confusion.

Pick an editor and stop shopping

VS Code is the common starting point: free, includes a terminal, and has a Python extension that provides completion and error highlighting. Alternatives that work just as well include PyCharm Community and the simpler editors bundled with some systems. The right choice is the one you will still be using next month.

  • Install the Python extension if your editor offers one.
  • Turn on format-on-save and let the editor handle spacing.
  • Learn three shortcuts: open file, integrated terminal, run current file.

Resist adding a dozen extensions before you have written a program. Each one adds a way for things to break.

Make a project folder before writing code

Create a folder with a plain name and no spaces, and open that folder as the project root. Inside it, expect a small, stable layout: your script files at the top level, a data folder for inputs, and a .venv folder that you never edit by hand. Keeping one project in one folder means the terminal, the editor, and your imports all agree on where things are.

Initialise a git repository in that folder on day one, even for practice code. A commit history is how you find the version that worked, and it costs two commands.

Create a virtual environment per project

Installing packages globally eventually breaks something, because two projects will want different versions of the same library. A virtual environment gives each project its own package set.

  1. In the project folder, run python -m venv .venv.
  2. Activate it: .venv\Scripts\activate on Windows, or source .venv/bin/activate on macOS and Linux.
  3. Confirm the prompt now shows the environment name.
  4. Install packages with python -m pip install name and record them in a requirements file.

Point your editor at that interpreter once, and it will use it for every run and every error squiggle.

The five terminal commands worth memorising

You do not need to be a command-line expert, but these cover most work: pwd to see where you are, ls or dir to list files, cd to move, python script.py to run your file, and python -m pip list to see what is installed. Add the up-arrow history key and you have enough to work comfortably.

Run your first file from the project root every time. Paths in code are resolved from the current directory, and most “file not found” errors are really “wrong directory” errors.