Starting Python Development on Windows

Posted in programming with tags python windows -

Summary

Notes on starting Python development, with specific details on using Microsoft Windows.

Installing Python on Windows

First, download the latest version of Python from the official Website. Choose the Windows x86-64 executable installer for the latest version of Python 3, unless you know that you need a different option.

Run the installer, and select the option to Add Python to PATH, so that you do not need to type the full path for Python commands. If prompted, choose the option to remove the path length limitation from Windows.

A standard Python installation provides you with:

  • The Python runtime
  • An interactive shell (use the menu icon, or type python in a command prompt window)
  • A basic IDE, called IDLE
  • A large standard library, along with documentation
  • An extensive tutorial, to help you get started

IDLE is intended as a basic and portable development environment that lets new programmers start without having to install a separate editor for their code. For a much better experience, install a text editor or IDE that supports Python.

The tutorial that is supplied with Python can walk you through the basics. The documentation for the standard library does provide simple examples for many features, but it is specifically designed as a reference, rather than for learning. The last section of this article gives you links to courses and books that you may find more helpful when starting with Python.

Choosing a Code Editor or IDE

If you are new to programming, start with Mu, which is specifically designed to help new developers work with Python. Otherwise, if you do not already have a preferred editor, consider Visual Studio Code. This tutorial shows you the features that Visual Studio Code has for Python development, including code quality checks, and support for debugging. Both of these editors are free.

If you would like to use a full IDE, there are several options available. Wing IDE and PyCharm are proprietary, commercial products. The free Eclipse IDE can be be used for Python development with the PyDev extension. Current versions of Microsoft Visual Studio also include support for Python.

Essential Tools

There are a number of de-facto standard utilities and libraries for Python software development, but a few tools are so fundamental that you should install them even before you begin to write Python code.

Git for Version Control

If you do not already use version control, you should also install Git on your system. Git is now effectively the standard version control tool for developers.

Version control is obviously vital for collaborating with other programmers. It also enables you to efficiently copy your application to other systems for testing, deployment and backup.

If Git is installed, Atom and Visual Studio Code provide you with access to information and features from Git directly in their user interfaces. If you use Visual Studio Code, you should also consider installing the Git Lens extension, which enhances the integration with Git.

pipenv for Virtual Environments

Install pipenv to manage your Python projects. It ensures that each of your Python projects use a separate set of packages, and provides other features to help you maintain your work, such as checking the code and warning you about security issues in libraries.

In a command prompt window enter the following command:

pip install pipenv

The pipenv tool uses the pip and virtual environment facilities that are included with Python itself, so it is fully compatible with other Python utilities, whilst being much easier to use than other tools. The Python packaging documentation now officially recommends pipenv.

The Python Guide tutorial shows you how to work with pipenv.

Building Graphical Desktop Applications

If you are specifically interested in developing desktop applications, start with wxPython. The Tk interface toolkit that is supplied with the Python standard library is rather basic and dated. If you have advanced needs, you may prefer PySide2, which enables you to make use of the QT libraries.

Microsoft Windows Integration

Python includes support for some features that are unique to Microsoft Windows, but not all of them. To use Python with other features of Windows, such as COM and the Registry, install the win32 Extensions.

Packaging Applications

To build packaged applications for Windows, use PyInstaller. This creates stand-alone executables that include Python itself, your code, and any other dependencies.

Learning Resources

Online Videos

The PyVideo site is an index of free videos on Python and related topics.

Corey Schafer’s YouTube channel provides introductory tutorials for getting started with Python and programming.

Books

There are several excellent books for learning Python 3 that you can read for free online. Dive Into Python 3 is particularly good for those people with some previous experience of programming, especially if they are impatient! If you are not a programmer, try Automate the Boring Stuff with Python, which includes a gentle introduction to programming.

Online Guides

Once you have learned Python itself, visit The Hitchhiker’s Guide to Python, which provides clear advice on daily work with Python, and Full Stack Python for a comprehensive guide to building Web applications with Python.

If you are a programmer or systems administrator, consider replacing bash scripting with Python.

This article lists useful tools and libraries for Python.