Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
356 views
in Technique[技术] by (71.8m points)

python - How to install pycairo on osx?

I am trying to install the pycairo (Python bindings for the cairo graphics library) under OSX.

I started with

easy_install pycairo

and got:

Requested 'cairo >= 1.8.8' but version of cairo is 1.0.4

error: Setup script exited with Error: cairo >= 1.8.8 not found

So I went to cairo's site and downloaded the latest package (1.8.8) of cairo, and also the latest package of something called pixman (both source packages -- couldn't find osx binaries)

unzipped both, each in own directory. for pixman, the regular ./configure ; make ; sudo make install worked just find for cairo, ./configure seemed to work, but make failed with:

In file included from cairo-analysis-surface.c:37:
cairoint.h:71:20: error: pixman.h: No such file or directory

What am I doing wrong?

And why do I have to struggle so much to get a software library to work on an os that "just works"? Why isn't darwin more like linux?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you already have homebrew, these two commands should be helpful:

$ brew install cairo --use-clang 
$ brew install py2cairo

For a non-Homebrew installed Python, set the PYTHONPATH to find pycairo. You can set your PYTHONPATH in your .bashrc/.profile/.whatever to the following:

PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH.

I personally didn't need to use this last part but it might help you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...