如何在 Windows 上安装 PyCairo (Cairo for Python)?

发布于 2024-12-24 03:12:10 字数 518 浏览 2 评论 0原文

今天下午我花了几个小时试图找到一个在 Windows 上安装 PyCairo 的简单教程。

Cairo 项目本身不维护 Windows 二进制文件,必须在其他地方下载它们(例如 http ://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/)。

由于 MSVC 显然不是 PyCairo 支持的编译器(尽管源补丁很简单),这一过程显然也变得更加复杂。请参阅此错误报告:

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

谁能推荐一个在 Windows 上安装 PyCairo 的教程?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

半世蒼涼 2024-12-31 03:12:10

您应该尝试 Gohlke 存储库中的 Windows 二进制安装程序 pyCairopy2Cairo

我自己从未使用过 pyCairo,但花了 4 分钟来安装并完成我的第一个 png 示例文件。

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.

终弃我 2024-12-31 03:12:10

添加以下内容以确保完整性 - 上面 joaquin 的答案提供了更简单的路线(以及 Python 3 支持)。


请参阅以下教程:

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

(也托管在 http://hal.elte.hu/~nepusz/development/igraph/教程/install.html)。

我问了上面的问题,以便我自己回答。希望将来遇到类似情况的人能够找到这篇文章:)

虽然谷歌搜索“pycairo install windows”确实给出了上面的链接,但它出现在一些相当无用的页面下面,而且 igraph 文档的适用性也不是特别明显。

最终我在没有开罗本身的情况下安装了 PyCairo(来自问题中的 GNOME 链接)。当我尝试使用它时,这给了我一个 DLL 导入错误。幸运的是,StackOverflow 上存在与此错误相关的问题:

​​pycairo“导入错误:DLL 加载失败:找不到指定的模块。”即使在安装了 DLL 之后

这个问题讨论了来自 Tamas 的优秀教程,链接在上面,这是我启动和运行所需的全部内容。

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.

錯遇了你 2024-12-31 03:12:10

我相信我已经使用 pygtk 一体化安装程序 安装了一个副本,并且我相信它确实可以工作(32b, python2,请注意)。他们还在您的帖子中提到了 gnome URL

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.

眼中杀气 2024-12-31 03:12:10

一站式安装 pygtk
http://www.pygtk.org/downloads.html
它包括 pygtk 及其所有依赖项,包括 pycairo

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

半步萧音过轻尘 2024-12-31 03:12:10

StackOverflow 中还有另一个类似的问题: PyCairo - Installation on Windows

接受的答案简单实用。

尽管它提供的链接已经过时(因为版本现已更新),但这个想法很棒。

我改进了这个答案,使其更通用:

  1. 转到 非官方 Windows 二进制文件对于 Python 扩展包 - Pycairo

  2. 下载 pycairo‑***.whl 文件(选择适合您的环境的版本)。

  3. 转到下载 .whl 文件的文件夹,然后输入 pip install pycairo-***.whl。等待几秒钟,一切都会完成。

我已经测试过这个方法并且效果非常好。

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.

浪漫之都 2024-12-31 03:12:10

现在 Pycairo 有轮子,请参阅 https://github.com/pygobject/pycairo/pull/191。

Windows 就可以

pip install pycairo

,他们会安装 pycairo。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文