SS123
SS123

Reputation: 11

Module 'cairo' has no 'Context' member

When I am trying to run this example, I am getting the following problem messages:

  1. Module 'cairo' has no 'ImageSurface' member
  2. Module 'cairo' has no 'Context' member
  3. Module 'cairo' has no 'FORMAT_ARGB32' member

What is the problem here?

Upvotes: 1

Views: 383

Answers (1)

jackdbd
jackdbd

Reputation: 5053

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.

Upvotes: 1

Related Questions