Pycairo is the binding for thecairo graphics library. It's also notsomething you can get running with a simple
pip install py2cairo
.After many hours of working the search engines and dancing to theconfigure/make/make install melody, I figured out an answer that workedfor me.- Pycairo currently does not support installation through pip/distutils. The project’s install docs instructs to use either waf or autotools. To use pycairo in a virtualenv, you need to: Install pycairo system-wide, preferably through your distribution’s packages; Then, either.
- The Pycairo bindings are designed to match the cairo C API as closely as possible, and to deviate only in cases which are clearly better implemented in a more ‘Pythonic’ way. Pip install pycairo Installing Pycairo requires cairo including its headers.
2019-11-13 I want to install the Python bindings for Cairo on Mac OSX Lion, so that I can use them with the Apple build of Python 2.7. I tend to install Python modules etc using easyinstall, but that doesn't.
If you don't have it yet, go gethttps://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkgand install it. It's 200 MB so make sure you have a fast connectionand/or a good place to wait.
I use Homebrew instead of Macports. If you don't have it yet, pastethis in a terminal prompt:
In your terminal prompt, type the following:
You'll get some messages about LDFLAGS and CPPFLAGS in build variables,but that's only important if you skip Homebrew and build your ownsoftware later that interacts with cairo.
The nasty little trick to this is to remember that Pycairo ispackaged on it's site and other places as py2cairo. When they getaround to releasing version 3 of Pycairo, I'm going to beg and pleadthat they follow an obvious naming system for their bundles. I know thisis done in other communities, but it's frustrating and a real barrierfor getting into a project.
In case, in your terminal prompt, type the following:
If you are using a non-Homebrew installed Python like I do, you have toset the PYTHONPATH to find pycairo. Set your PYTHONPATH in your.bashrc/.profile/.whatever to the following:
Yes, it's the system Python, but for now I'm okay with it. If someonehas an easy recipe for alternative Python installations, I would love tolink to it.
How to install pycairo on osx? (5)
I found this instruction very helpful and much less confusing. I am on Yosemite and it worked very well for me. This instruction uses homebrew to install. So if you already have homebrew, these two commands should be helpful:
![Extension Extension](/uploads/1/2/4/3/124382231/276441090.jpg)
For a non-Homebrew installed Python, this instruction suggest to set the PYTHONPATH to find pycairo. You can set your PYTHONPATH in your .bashrc/.profile/.whatever to the following:
![Install Install](/uploads/1/2/4/3/124382231/387150187.jpg)
I personally didn't need to use this last part of the instruction but it might help you.
I am trying to install the pycairo (Python bindings for the cairo graphics library) under OSX.
I started with
and got:
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 findfor cairo, ./configure seemed to work, but make failed with:What am I doing wrong?
Python Whl
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?
Pycairo Whl
It appears you are mixing various install options here. The MacPorts package system
port install
command should automatically pull in all the dependencies needed for a particular package so the trick is to start with the right top-level project. For python packages, MacPorts has a general convention currently: packages that start with py-
are for python 2.4, those with py25-
are for 2.5, and py26-
for 2.6. There are currently py-cairo
, py25-cairo
, and py26-cairo
packages available in MacPorts.By choosing
py-cairo
you picked the python2.4 version and you'll probably find that MacPorts built and installed a python2.4 for you (linked at /opt/local/bin/python2.4
) and, if you launch it, you'll probably find that you can import cairo there. Now that may be OK for your needs but Python 2.4 is quite old and no longer supported so, if you're just starting, it might be better to start with Python 2.6, one of the two current versions of Python. To do so, all you should need to do is:That should bring in any missing dependencies, mainly the MacPorts python2.6, which you can run from
/opt/local/bin/python2.6
. You may want to change your $PATH
in your shell startup script, probably .bash_profile, to put /opt/local/bin
early on the search path.Because installing Cairo and its python bindings seems to be fairly complex, it should be easier and better to stick to using a complete MacPorts solution for this. That does mean you've needlessly (and harmlessly) installed a couple of Python instances that you won't need. But if you do want to clean things up a bit, you can easily remove the MacPorts python24 with:
How To Install Pycairo Install In Windows
Completely removing the python.org installed python is more complicated. I've explained the process here. But there's no pressing need to remove either as long as you keep your paths straight.