Search code examples
pythoncommand-linepipwindows-runtime

Why can't pip find winrt?


I just bought a new laptop and I'm trying to set it up with python. I am using python 3.10.0, windows 10, pip v21.3. For the most part, pip seems to be working correctly, I've already used it to install multiple packages such as pygame. When I try to install winrt, however, I get this error

C:\Users\matth>pip install winrt
ERROR: Could not find a version that satisfies the requirement winrt (from versions: none)
ERROR: No matching distribution found for winrt

My old laptop is still able to uninstall and reinstall winrt using pip without a problem, and again pip works on my new laptop for other packages, just not winrt. Any idea what the problem is and how I fix it?


Solution

  • Microsoft has not been maintaining the winrt package. There is no binary wheel for Python 3.10 as seen on PyPI. There is also a request for this on GitHub.

    I have started a community-maintained fork of the PyWinRT project. You can install and use winsdk instead. It supports Python 3.10. Just replace winrt with winsdk in your imports. EDIT: Since September 2023, the monolithic winsdk package was getting too big, so it has been replaced by individual winrt-* packages for each WinRT namespace. winrt-runtime is the base shared runtime support package and each namespace has a package similar to winrt-Windows.Foundation.

    Documentation can be found here.

    A list of improvements and bug fixes compared to the winrt package can be found in the changelog.