How do you install PyCairo (Cairo for Python) on Windows?
Asked Answered
Q

7

23

I spent hours this afternoon trying to find a straightforward tutorial for installing PyCairo on Windows.

The Cairo project itself does not maintain Windows binaries, they must be dowloaded elsehere (e.g. http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/).

The process is also complicated further apparently by the fact that MSVC is apparently not a supported compiler for PyCairo (although the source patch is simple). See this bug report:

https://www.libreoffice.org/bugzilla/show_bug.cgi?id=22940

Can anyone recommend a tutorial for installing PyCairo on Windows?

Qadi answered 2/1, 2012 at 19:7 Comment(2)
the hyperlink you give points to repositories with old pycairo versions. There are neither version for python 3.x. See my answer for updated installers for python 2.x and 3.xDecal
Thanks joaquin, that's perfect. I've removed my answer from the question, as planned.Qadi
D
28

You should try windows binary installers from Gohlke repository for pyCairo and py2Cairo.

I never used pyCairo myself but took 4 minutes to install and get my first png example file done.

Decal answered 2/1, 2012 at 19:16 Comment(3)
I have downloaded whl file and install but this issue.ERROR: pycairo-1.19.1-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.Keeney
@daurenslambekov That's probably because you have a 32 bit version of Python and downloaded a 64 bit version of pycairo OR you downloaded the 3.9 version of the library and have a Python 3.8 or below.Naos
@joaopaulo.ps93 thanks so much for the detailed comment!Poon
Q
7

Adding the following for completeness - joaquin's answer above provides a simpler route (and Python 3 support).


Please see the following tutorial:

http://www.cs.rhul.ac.uk/home/tamas/development/igraph/tutorial/install.html

(also hosted at http://hal.elte.hu/~nepusz/development/igraph/tutorial/install.html).

I asked the question above, so that I could answer it myself. Hopefully people in a similar situation in future will find this post :)

While Googling "pycairo install windows" does give the above link, it is presented below some rather unhelpful pages, and it's also not particularly obvious that igraph documentation will be applicable.

Eventually I got as far as installing PyCairo (from the GNOME link in the question), without Cairo itself. This gave me a DLL import error when I tried to use it. Fortunately, a question relating to this error exists on StackOverflow:

pycairo "ImportError: DLL load failed: The specified module could not be found." even after DLLs installed

This question discusses the excellent tutorial from Tamas, linked above, which is all I needed to get up and running.

Qadi answered 3/1, 2012 at 9:30 Comment(1)
Already made this comment on another answer but in case it helps someone; I had conflicting DLLs and the solution was stupidly simple... had to move the GTK (ex: C:\gtk\bin) to the beginning of my environment variables.Wynnie
L
5

I believe I have installed a copy using the pygtk all-in-one installer and I believe it did Just Work (32b, python2, mind you). They also mention the gnome URL in your post.

Loverly answered 11/1, 2012 at 14:51 Comment(2)
Good to know. The question discusses installing just PyCairo. However, having done this and used it for a few days, I'd probably recommend installing the full PyGTK suite as you mention. Being able to render your work to a window during dev, even if your ultimate target is rendering to file, is really helpful and speeds things up!Qadi
Me too, much simpler way. Unless you have a reason not to install GTK this is what I'd recommend.Demonology
R
2

install pygtk all in one http://www.pygtk.org/downloads.html It includes pygtk and all its dependencies, including pycairo

Ruvolo answered 10/8, 2013 at 20:33 Comment(0)
I
1

A simple tutorial: http://digitalpbk.blogspot.com.au/2012/03/installing-pygtk-pypango-and-pycairo-on.html

only 4 steps and worked like a charm.

Isoagglutination answered 25/1, 2013 at 4:0 Comment(1)
I was stuck for a while with conflicting DLLs installed with this method. The solution was stupidly simple... had to move the GTK (ex: C:\gtk\bin) to the beginning of my environment variables.Wynnie
R
1

There is another similar question in StackOverflow: PyCairo - installation on Windows

The accepted answer is simple and practical.

Although the link it provided is outdated (because the version is up now), the idea is great.

I improve that answer to make it more general:

  1. Go to Unofficial Windows Binaries for Python Extension Packages - Pycairo

  2. Download the pycairo‑***.whl file (choose a proper version for your environment).

  3. Go to the folder where you download the .whl file and type pip install pycairo-***.whl. Wait a few seconds and everything would be done.

I have tested this method and it works perfectly.

Rolon answered 19/7, 2018 at 6:15 Comment(0)
T
1

Now Pycairo has wheels see https://github.com/pygobject/pycairo/pull/191.

Windows can just do

pip install pycairo

and they will have pycairo installed.

Token answered 9/10, 2020 at 10:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.