Skip to content Skip to sidebar Skip to footer

Module 'cairo' Has No 'context' Member

When I am trying to run this example, I am getting the following problem messages: Module 'cairo' has no 'ImageSurface' member Module 'cairo' has no 'Context' member Module 'cairo

Solution 1:

Pycairo requires cairo C header files to be installed on your system. It's written in the "Getting Started" section of the documentation.

The reason why the example worked with Anaconda is because Anaconda installed cairo as a conda package.

A conda package is built using a conda recipe (e.g. here is the one for cairo) by a tool called conda-build. When the cairo conda package is being built, conda-build follows what it's written in the meta.yaml file of the conda recipe. As you can see from meta.yml file, cairo is downloaded as a tarball. Then if you are on Windows, conda-build runs the bld.bat file and compiles cairo. Otherwise, if you are on Linux or macOS, conda-build does the same thing using the build.sh file. In other words, Anaconda (via conda-build) installed the cairo C header files for you.

Note: I'm not a conda expert, and I think oversimplified the process how conda-build works. If you are interested, here is a link to the official conda-build documentation.

Post a Comment for "Module 'cairo' Has No 'context' Member"