Microsoft Windows

Python programming on Microsoft Windows.

On Windows, pywin32 gives Python the Win32 API and COM, from registry keys to Excel. Calling .NET needs a Python Windows library of its own: pythonnet.

How to choose:

  • Win32 API calls, the registry, the event log, or COM automation of apps like Excel: pywin32
  • .NET assemblies from Python, or Python embedded in a .NET app: pythonnet
  • Several Python versions on one machine, switched per folder: pyenv-win
  • A portable Python that runs from a folder, a network share, or a USB key: WinPython

Listed in editorial order. Click a column header to re-sort the whole list.

Press / to search. Tags open their category. Click a row for details.

Search and filter

Results

Row number Tags
Python extensions for Windows.
mhammond/github.com/mhammond/pywin32 /5,632 stars /
Python integration with the .NET Common Language Runtime (CLR).
pythonnet/github.com/pythonnet/pythonnet /5,534 stars /
A Python version manager for Windows (rbenv-win fork).
pyenv-win/github.com/pyenv-win/pyenv-win /7,420 stars /
Portable Python distribution for Windows.
winpython/github.com/winpython/winpython /2,291 stars /

Microsoft Windows guide

pywin32 provides access to many of the Windows APIs, including COM. Install it with python -m pip install --upgrade pywin32. Outside a virtual environment, its post-install script sets up COM objects and services. Never run it inside one. To drive an app over COM, pass its name to win32com.client.Dispatch(), like "Excel.Application". Then call its methods and set its properties as on any Python object.

pythonnet integrates CPython with the .NET runtime instead of compiling Python to .NET code, so your existing Python code and C extensions keep working. Install it with pip install pythonnet. Pick the runtime before you import clr, with load("coreclr") or the PYTHONNET_RUNTIME environment variable, or you get the default one. Then load each assembly with clr.AddReference() and import its namespaces like Python packages. It also works the other way, to embed Python in a .NET app.

pyenv-win brings pyenv to Windows, so you get pyenv's commands for switching between Python versions. Install it with the PowerShell script from its quick start, then set your default with pyenv install <version> and pyenv global <version>. In a project folder, pyenv local <version> picks the Python that python runs there, with nothing to activate.

WinPython is a portable Python distribution. Unzip it anywhere, like a network share or a USB key, and it runs, with nothing installed or written to the registry. Pick a build by how much comes preinstalled: a bare Python you fill yourself, or the scientific stack with Spyder and JupyterLab ready to open. Add packages with pip or wppm, then zip the folder and hand it to your students or colleagues.

Know a project that belongs here?

Tell us what it does and why it stands out.