简体   繁体   English

pycairo 在 osx 上安装错误

[英]pycairo install error on osx

While I am installing pycairo using easy_install on osx, there is an error message as following:当我在 osx 上使用 easy_install 安装 pycairo 时,出现如下错误消息:

Searching for pycairo
Reading http://pypi.python.org/simple/pycairo/
Reading http://cairographics.org/pycairo
Best match: pycairo 1.10.0
Downloading http://cairographics.org/releases/pycairo-1.10.0.tar.bz2
Processing pycairo-1.10.0.tar.bz2
error: Couldn't find a setup script in /tmp/easy_install-hnheQI/pycairo-1.10.0.tar.bz2

Please help me out.请帮帮我。 Thanks in advance.提前致谢。

It looks like pycairo is not set up to be easy_install able (or pip able).看起来 pycairo 没有设置为easy_install能力(或pip能力)。

The first problem is that the PyPI package pycairo points at the Python 3.x version, not the 2.x version (which is called py2cairo) This means you can't easy_install or pip install it for 2.x.第一个问题是 PyPI 包 pycairo 指向的是 Python 3.x 版本,而不是 2.x 版本(称为 py2cairo)这意味着您无法为 2.x pip install easy_installpip install它。 And they don't have a separate py2cairo PyPI package.而且他们没有单独的 py2cairo PyPI 包。 So, you'd have to explicitly easy_install http://cairographics.org/releases/py2cairo-1.10.0.tar.bz2 .因此,您必须明确easy_install http://cairographics.org/releases/py2cairo-1.10.0.tar.bz2

The second problem is that the tarball isn't designed to be built with setuptools ;第二个问题是 tarball 不是为使用setuptools you have to use waf .你必须使用waf

So, you're going to have to download the link above (or, better, the latest py2cairo at http://cairographics.org/pycairo/ ), untar it, and read and follow the INSTALL directions.因此,您将不得不下载上面的链接(或者更好的是,在http://cairographics.org/pycairo/上下载最新的 py2cairo),解压缩它,然后阅读并按照安装说明进行操作。

This also assumes that you already have Cairo installed properly (eg, via Homebrew).这也假设您已经正确安装了 Cairo(例如,通过 Homebrew)。

PS, not that it would make any difference here, but you really should be using pip instead of easy_install . PS,并不是说它在这里会有什么不同,但是您确实应该使用pip而不是easy_install The only times you want to use easy_install are to install pip itself ( sudo easy_install pip ), and to install two or three packages that are easy_install able but not pip able.您想要使用easy_install的唯一时间是安装pip本身( sudo easy_install pip ),并安装两个或三个支持easy_install但不支持pip包。

You mentioned that you got Cairo through MacPorts.你提到你是通过 MacPorts 到达开罗的。 MacPorts doesn't play well with non-MacPorts. MacPorts 不能很好地与非 MacPorts 配合使用。 In fact, that's kind of the point: to have a completely isolated set of tools and libraries that can be maintained together.事实上,这就是重点:拥有一套完全独立的工具和库,可以一起维护。 This means if you have MacPorts' cairo , you probably want its py27-cairo , and python27 package.这意味着如果你有MacPorts的cairo ,你可能希望它py27-cairopython27包。

If you want something better integrated with your system, either look for binaries, use Homebrew , or build it yourself.如果你想要更好地与你的系统集成,要么寻找二进制文件,使用Homebrew ,或者自己构建它。 (I noticed that Homebrew also has a formula for py2cairo , which I believe will install into your system 2.7 Python, but I haven't tested it. Normally, Homebrew doesn't supply Python/Ruby/Perl modules, because you've already got pip / gem / cpan , but they make exceptions for packages that don't work with the standard tools and/or are hard to set up.) (我注意到 Homebrew 也有一个py2cairo的公式,我相信它会安装到你的系统 2.7 Python 中,但我没有测试它。通常,Homebrew 不提供 Python/Ruby/Perl 模块,因为你已经得到了pip / gem / cpan ,但它们对不能使用标准工具和/或难以设置的包进行了例外处理。)

Step 1: Run this from terminal ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null 步骤1:从终端ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

Step 2: brew install cairo 步骤2: brew install cairo

Step 3: pip install pycairo 步骤3: pip install pycairo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM