模块"cairo"没有“上下文"成员 [英] Module 'cairo' has no 'Context' member

查看:58
本文介绍了模块"cairo"没有“上下文"成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行此示例时,我收到以下问题消息:

  1. 模块"cairo"没有"ImageSurface"成员
  2. 模块"cairo"没有上下文"成员
  3. 模块"cairo"没有"FORMAT_ARGB32"成员

这是什么问题?

解决方案

Pycairo 需要cairo C标头要在系统上安装的文件.它写在文档的入门" 部分.

该示例与Anaconda一起使用的原因是,Anaconda将cairo安装为 conda软件包.

使用conda配方构建一个conda软件包(例如此处是一个适用于开罗),使用名为conda-build的工具.在构建cairo conda软件包时,conda-build遵循 meta.yaml 文件.从 meta.yml 文件中可以看到,cairo是作为tarball下载的.然后,如果您使用的是Windows,conda-build将运行bld.bat 文件并编译cairo.否则,如果您使用的是Linux或macOS,conda-build会使用 build.sh 文件.换句话说,Anaconda(通过conda-build)为您安装了cairo C头文件.

注意:我不是conda专家,我认为简化了conda构建的过程.如果您有兴趣,这里是指向官方的链接.conda-build文档.

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?

解决方案

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.

这篇关于模块"cairo"没有“上下文"成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆