Installation

Overview

pywin32 only supports the Windows operating system 😉 and Python ≥ 3.6. Release 228 is the last to support Python 2. Binary releases are deprecated.

Todo

  • Add commentary about using Virtual Environments.

  • Add commentary about whether pywin32 works from WSL2.

PyPI

Install pywin32 from PyPI with pip from the Command Prompt or Windows PowerShell:

❯ python -m pip install --upgrade pywin32

If you encounter any problems when upgrading (e.g., “module not found” errors), execute:

❯ python Scripts/pywin32_postinstall.py -install

This will make some small attempts to cleanup older conflicting installs.

Note

To use pywin32 for system-wide features, such as registering COM objects or implementing Windows Services, run pywin32_postinstall.py from an elevated command prompt (i.e., “Run as Administrator”).

Build from source

Building from source requires Visual Studio and the Windows SDK. Some free compilers probably work but have not been tested. Let me know your experiences!

Install using setup.py:

❯ python setup.py install

or

❯ python setup.py --help

You can run setup.py without any arguments to see specific information about dependencies. A vanilla MSVC installation should be able to build most extensions and list any extensions that could not be built due to missing libraries. If the build actually fails with your configuration, please open an issue.

Pre-release builds

For unreleased changes, download builds made by GitHub Actions:

  • Choose any “workflow” from the main branch

  • Download its “artifacts”

Binary releases

Deprecated since version 305: Install from PyPI instead. See Release 305 notes.

pywin32 traditionally offered pywin32.exe files for installation. This is going to stop soon.

Support for building pywin32.exe installers was removed from setuptools. At some point in the future they cannot be provided.

While they are still provided, find them on GitHub.

Run as a Windows Service

Modern Python installers do not, by default, install Python in a way that is suitable for running as a service, particularly for other users.

Ensure Python is installed in a location where the user running the service has access to the installation and is able to load pywintypesXX.dll and pythonXX.dll.

Manually copy pythonservice.exe from the site-packageswin32 directory to the same place as these DLL files.

Troubleshooting

A very common report is that people install pywin32, but many imports fail with errors similar to “The specified procedure could not be found” or “Entry-point not found”.

In almost all cases, this tends to mean there are other pywin32 DLLs installed in your system but in a different location than the new ones. This sometimes happens in environments that ship with pywin32 (e.g., Anaconda).

The possible solutions are:

  • Run the pywin32_postinstall.py script documented above.

  • Find and remove all other copies of pywintypesXX.dll and pythoncomXX.dll (where XX is the Python version (e.g., 39 for Python 3.9).