Packaging TeX Live For MSYS2

Installing Pycairo In Windows

So, you have been here just to install a Python Library in Windows. Let me give an introduction about it.
Install Pycairo in windows officail and unoffical method

What is Pycairo?

Pycairo is a Python module providing bindings for the Cairo graphics library. It depends on Cairo >= 1.13.1 and works with Python 3.5+. Also, Cairo is a 2D graphics library with support for multiple output devices. Currently, supported output targets include the X Window System (via both Xlib and XCB), Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. So, you can create beautiful Images using Programs in Python after installing Pycairo. You could have tried something like
pip install pycairo
But it usually fails if your PC is not configured for it. You may find the below guide helpful if you want to install it.

Installing Pycairo

Installing Unofficial Binaries - Easiest One

Installing using this method is considered unofficial as Pycairo as of  4 July 2020, not yet provides Wheels (Binaries) which would make the install easy, can be directly installed pip. Now, in this method, we are downloading those binaries from another site and installing it in your PC. So you can follow the steps below for it.

➜ Using the Script from Manim Community

This method uses the script which was created and maintained by the folks of Manim Community. Sometimes the URL may fail because those binaries are not hosted in the same place. So if you are lucky enough it may work for you and you would just complete it vary easily.
  1. Open Powershell or any other Elevated Command Shell which is Supported for Web Requests.
  2. Copy and Paste the below command in it.
  3. (Invoke-WebRequest -Uri -UseBasicParsing).Content | py -3
  4. That you would automatically install PyCairo if it succeeds with no Error. If this fails Follow other methods below. Also, if that method fails you can open an issue here.

➜ Directly downloading Binaries

  1. Go and visit the Download Page.
  2. Select the download that corresponds to your PC's architecture and Python Version.

    pycaairo install using wheel eay method
  3. cp38 corresponds to Python 3.8, cp37 corresponds to Python 3.7, etc win_amd64 corresponds to 64-bit machines, win32 corresponds to 32-bit machines. You could see for more reference.
  4. Open your Command Prompt and enter the directory where you downloaded the file by typing
    cd C:\path\to\cairo
  5. Finally, run pip install (cairo-file).whl, where the file the appropriate name of the .whl file. For example, see below.
    pip install pycairo-1.19.1-cp38-cp38-win_amd64.whl 

    If you have multiple Python version installed use below to select the version.
    py -3.8 -m pip install pycairo-1.19.1-cp38-cp38-win_amd64.whl
  6. Here, I selected Python 3.8 above. If import pycairo works then you are good to go. This would complete the installation of PyCairo.

Installing Official Binaries - Requires C compiler

If you are the person, who wants actually need to compile from the source or from the using pip. You should first get suitable C compilers. Refer Python Wiki for your required C compiler. You should get your Cairo binaries from or build the one you need refer if you want to build it.

After that set the environment variable INCLUDE to point to the path of binaries INCLUDE FOLDER. And also another environment variable called LIB and the value is to the path where cairo.dll and cairo.lib is located. You could see below for setting it.

setx INCLUDE C:\path\to\header\files
setx LIB C:\path\\to\dll\files
After that, the below default pip install would work.
pip install pycairo
Great you have successfully installed PyCairo and import pycairo works.