How to get started with Python

A complete guide to choosing the right Python distribution, the right Python IDE, and the right supporting tools to jumpstart your Python programming.

How to get started with Python
Sviatlana Zyhmantovic/Shutterstock

Python is often described as an easy language—both easy to learn and easy to use. Python makes it easy to develop powerful software for an enormous variety of applications. But it can be as difficult to get started with Python as with any other programming language. Every choice you make will matter. The Python operating system and runtime you use will matter, as will the IDE or editor you use to write your code.

In this article, we’ll walk through the steps needed to get your “sea legs” with Python. We’ll discuss the different Python distributions, the leading development environments, and supporting tools you might want for your Python workspace, such as code formatters, project templates, and virtual environments. Being informed about your options will help you avoid some of the pitfalls that come with putting together a Python programming environment.

Choose a Python version

For many years, Python existed in two parallel incarnations—the older Python 2.x branch, kept alive to support legacy Python applications, and the newer Python 3.x branch. At this point, the only version you should be using as a new Python user is the 3.x series.

New releases for Python come out roughly once per year, typically in October. As of January 2024, for instance, the newest release version is Python 3.12. However, as a general rule, it's often best to go with a version that's one revision behind the current one, the better to ensure maximum compatibility. In this case, consider using version 3.11 instead of 3.12. Some Python libraries lag in compatibility, and won't work with the most recent releases.

Choose your Python platform

How you get started with Python will depend mainly on the operating system you’re planning to use as your development environment. Fortunately, Python is available for all the major operating systems, and so are good Python editors and development environments. Whatever OS you're comfortable with will be a decent choice.

Before you install anything: The instructions in this section are for installing the stock, standard version of Python produced by the Python Software Foundation. Python is available in other editions as well. The section “Pick a distro” goes into detail about this, but the standard version of Python is suitable for most basic use cases.

Microsoft Windows

Python doesn’t ship by default with Windows, but adding Python to Windows is generally no more complicated than downloading a runtime and clicking a few buttons. You can download installers from the Python for Windows release page.

If you use the winget package manager for Windows (which is a good idea), you can obtain editions of Python by typing winget search "Python 3" to find the IDs for specific versions to install. Do not install the versions that list msstore as the source, however—only install the ones that use winget as the source. For instance, to install Python 3.11, you'd use winget install Python.Python.3.11. (See my intro to Winget for more about the Windows package manager.)

Linux

Python is a standard-issue package on just about every major Linux distribution. The question is whether or not you will have the most recent version of Python installed by default. Some Linux distros bundle an older version of Python on purpose. For instance, Python scripts written for that particular distribution may rely on a given version of Python.

If that’s the case, you may need to use the package manager for your distribution to install another version of Python. If you want to avoid clashes with the version already installed, the pyenv project allows you to designate which of multiple installed versions of Python you want to use as the default. It also allows you to set a Python version for a specific project.

macOS

Once upon a time, macOS shipped with the 2.x incarnation of Python. This actually made it more complicated to use Python on macOS, since the system-installed Python was meant more for the OS itself and its tooling than for end users.

Today, macOS doesn't bundle Python by default, so one has to install Python in some form no matter what. The most common and battle-tested way to do this is through pyenv. A common way to install pyenv on macOS is through the Homebrew package management system, using brew install pyenv.

Cross-platform

If you have Docker installed, you might simply obtain a Docker container with a Python runtime and use that as the basis for a project. This is probably the best way to go if you eventually intend to deploy the app in question by way of Docker; you might as well get started on the right foot.

Choose a Python distribution

Python is available by way of different distributions, or repackagings of the language and runtime. Just as different Linux distributions are meant to satisfy different use cases, the different Python distributions appeal to distinct audiences and usage scenarios.

Note that what follows isn’t a definitive list of Python distributions. Many others are available that cover similar use cases, but these are the best-known and most widely used.

CPython

This is the default Python runtime, created by the Python Software Foundation, and the most general-purpose version of Python. In addition to the interpreter and the standard library, it includes a passel of third-party components commonly shipped with a Python interpreter (one example is the SQLite database).

Note that CPython does not come with technical support directly, since it is not provided by a vendor. It does have a built-in mechanism for adding third-party packages, called pip, but larger and more complex packages—especially those for Windows with binary dependencies—are sometimes challenging to get running.

Use case: It's hard to go wrong choosing the stock CPython distribution, although you will have to set up and manage things yourself. That's also a good way to learn how things work in Python from the inside out.

ActivePython

ActiveState markets a whole slew of commercial and enterprise-grade language runtimes and IDEs. ActivePython includes the core CPython runtime and pre-installs dozens of vetted editions of popular third-party libraries used across a range of disciplines. Because of this, it requires less thumb-wrestling than CPython to get things to work. ActivePython also adds performance improvements for many of Python’s math and science libraries by way of the Intel Math Kernel Library.

ActivePython used to be offered in a free community edition with no support channel, but that has been phased out in favor of a free tier on the ActiveState Platform service. Paid versions provide tech support, local installs of ActivePython, support for end-of-life Python editions, indemnification, and many other bonuses. Prospective enterprise users can start from the bottom of that pyramid and work their way up to see if ActivePython is a good fit for their projects.

Use case: This distro is ideal for enterprise users who want hands-free access to common third-party libraries and who may want paid support.

PyPy

A drop-in substitute for CPython, PyPy’s big distinction is that it accelerates Python applications by way of a JIT (just-in-time) compiler. Some of the speedups can be dramatic, up to multiple orders of magnitude. However, the performance improvements will manifest most prominently in long-running applications, rather than, say, automation-style scripts that execute and quit.

Use case: PyPy is a great choice for developers of long-running services where Python’s dynamism becomes useful, and where C extensions aren’t used as much.

Anaconda

One of Python’s big use cases is for math and statistics—think engineering, data analysis, and machine learning. Of the Python distributions devoted to those use cases, Continuum Analytics’s Anaconda is among the best-known and most widely used. Like ActivePython, it bundles many common Python libraries for math and statistics and uses the Intel-optimized versions of math libraries wherever possible. Anaconda also provides its own installer for managing third-party libraries, making it easier to keep those packages up to date by managing their binary dependencies.

Use case: Anaconda will be of interest to anyone using Python for data analysis or machine learning. It isn’t limited to those use cases but is heavily optimized for them.

Choose your Python IDE

In theory, you don’t need anything more than a text editor and a Python runtime to develop software in Python. In practice, an IDE with Python support comes in mighty handy when developing anything more than a trivial script.

If you are already developing software with an IDE, you can probably use it for your Python programming, too. Most popular IDEs have robust Python support:

  • Both Microsoft IDEs—Visual Studio and Visual Studio Code—provide excellent Python support through extensions, so anyone with a workflow already built atop those IDEs just needs to install the appropriate add-ons.
  • Eclipse, widely used for Java but also other languages, supports Python through add-ons. Alternatively, you could use LiClipse, an edition of the Eclipse IDE with Python-supporting add-ons pre-installed and ready to go.
  • Many macOS users praise the Sublime Text editor for its speed, simplicity, and power, and it too has Python support. Sublime Text even has an integrated Python interpreter, and many of its plug-ins are written in Python, making it easy for Python developers to accentuate their workflow with Sublime Text.
  • Vim and Emacs both have strong Python support that can be augmented further. Vim has the python-mode plug-in, and Emacs has basic Python support that can be enhanced with add-ons.

Many dedicated IDEs for Python also exist, covering a variety of use cases:

  • IDLE, bundled with CPython, is suitable for tossing together quick scripts and helping those new to the language get their bearings.
  • PyCharm, from JetBrains, comes widely recommended, and it’s not hard to see why. It supports a great many tools native to the Python world (e.g., Jupyter notebooks), but also strives to make those tools accessible and easy to work with.
  • Spyder aims mainly at the science-and-stats crowd, rather than Python software developers, but it includes valuable aids like built-in support for Jupyter notebooks.

A word about Python packages

If you’re using a distribution like ActivePython or Anaconda, many common third-party Python libraries are either preinstalled or made available by way of a tool for obtaining more packages from the IDE maker’s own repositories. If you’re using CPython or another distribution that doesn’t provide these kinds of conveniences, adding third-party libraries is a little trickier.

The Python Software Foundation maintains a massive repository of third-party libraries, known as the Python Package Index (PyPI). Any package in PyPI can be added to a Python installation by way of the pip command-line tool. However, some packages require binaries built for specific platforms, and not every package in PyPI has binaries for every platform. Overcoming this problem isn’t difficult in Linux, which generally allows building those binaries on the fly, but doing it in Windows is less straightforward.

Python for Windows users

For certain kinds of Python projects, Windows users will need to do a little more manual lifting than users of Linux, macOS, and other Unix-based systems. One commonly missing ingredient that must be supplied by the Windows developer is a C compiler. For some packages, Python will need a C compiler to build certain modules when those modules aren’t provided in binary format. Cython, which translates Python into C code, needs a C compiler to produce working binaries.

The good news is that Microsoft’s own C compiler can be obtained and installed for free by way of Microsoft Visual Studio Community Edition. The easiest way to get the needed pieces is to install the Visual Studio Build Tools, the command-line components used by Visual Studio to perform actual compilation. You can install those with the winget package manager: winget install Microsoft.VisualStudio.2019.BuildTools (for the 2019 edition), or winget install Microsoft.VisualStudio.2022.BuildTools (for the 2022 edition).

It is also possible to install GCC (the Gnu Compiler Collection) by way of a project like Cygwin or MSYS2. However, because the Visual Studio C compiler is used to build CPython on Windows, using Visual Studio guarantees more consistency between binaries.

Finally, Windows doesn’t include revision control software, such as Git. IDEs that integrate with Git will balk if they don’t find it. You can obtain Git for Windows manually or install it by way of Winget (winget install Git.Git).

Tools for your Python workspace

Once you have your basic Python workspace set up, there are a few additional, supporting tools you'll want to consider. We'll look at those next.

Keep your Python code clean

Most programming languages have some way to perform code linting and syntax standardization. In Python, a collection of packages handles this work. All of the major IDEs have some manner of integrated support for them, so they’re worth adding to your workspace.

1 2 Page 1
Page 1 of 2