Install & Compatibility
Where this runs
tested against v0.2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.1MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
version
✓ from win32ctypes import version
✗ from win32ctypes import win32api
This example demonstrates how to import and use `win32api` to load and free a library, mimicking typical `pywin32` usage for basic API calls.
import sys
from win32ctypes.pywin32 import win32api
# Equivalent to 'import win32api' from pywin32
# Example: Load a library as a data file
try:
h_module = win32api.LoadLibraryEx(sys.executable, 0, win32api.LOAD_LIBRARY_AS_DATAFILE)
print(f"Successfully loaded {sys.executable} as a data file. Handle: {h_module}")
win32api.FreeLibrary(h_module)
print("Successfully freed the library.")
except Exception as e:
print(f"An error occurred: {e}")
Debug
Known issues
gotchapywin32-ctypes is a *partial* reimplementation of pywin32. It implements only a small subset of the pywin32 API, primarily for internal needs at Enthought, meaning many functions available in standard pywin32 may not exist or behave identically.fixUsers should refer to the pywin32-ctypes documentation for the specific APIs that are implemented and their behavior.
affects: All versions
breakingVersion 0.2.1 and later of pywin32-ctypes dropped support for Python versions older than 3.6.fixProjects targeting Python 2.x or Python 3.3-3.5 will need to use `pywin32-ctypes<0.2.1` or upgrade their Python environment to 3.6 or newer.
affects: 0.2.1 and later
breakingpywin32-ctypes version 0.1.2 fails to install with `setuptools>=58.0.0` due to its reliance on `use_2to3`, which `setuptools` no longer supports.fixUpgrade to `pywin32-ctypes` version 0.2.0 or newer, which has removed `use_2to3`. Alternatively, pin `setuptools` to a version older than 58.0.0 if using `pywin32-ctypes==0.1.2`.
affects: 0.1.2
gotchaApplications packaged with PyInstaller that include `pywin32-ctypes` (especially when interacting with sensitive Windows APIs like credential management) have been reported to be flagged as malware by antivirus software or corporate security policies.fixConsider code signing your executables or seeking whitelisting for your application. This issue stems from how some security software perceives `ctypes`-based interactions with low-level Windows APIs.
affects: All versions
gotchaPrior to version 0.2.3, issues existed in the backend selection logic (`loal_module`), which could lead to unexpected behavior when pywin32-ctypes attempts to choose between its `ctypes` and `cffi` backends.fixUpgrade to `pywin32-ctypes` 0.2.3 or newer to benefit from fixes in backend selection and ensure consistent runtime behavior.
affects: <0.2.3
breakingpywin32-ctypes is designed for Windows environments. Attempting to use it on non-Windows operating systems (e.g., Linux, macOS) will result in an ImportError as it tries to import Windows-specific functions like `get_last_error`, `FormatError`, and `WinDLL` from the `ctypes` module, which are not available on other platforms.fixDo not use `pywin32-ctypes` on non-Windows operating systems. This library is specifically intended for Windows-based projects.
affects: All versions
breaking`pywin32-ctypes` versions prior to a fix are incompatible with Python 3.13 due to their reliance on `ctypes.get_last_error`, which was removed from Python's standard `ctypes` module in version 3.13.fixUse Python versions older than 3.13, or upgrade `pywin32-ctypes` to a version that addresses this compatibility issue with Python 3.13.
affects: All versions prior to a fix
Upgrade
Version history
0.2.3latest on PyPI · released Aug 14, 2024
Audit
Dependencies
cffioptionalUsed as an optional, faster backend if available.