How to install pycairo on osx?

2024/10/15 0:20:26

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.4error: 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?

Answer

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.

https://en.xdnf.cn/q/69351.html

Related Q&A

How do I change a value in a .npz file?

I want to change one value in an npz file.The npz file contains several npys, I want all but one ( run_param ) to remain unchanged and I want to save over the original file.This is my working code:DATA…

How to load *.hdr files using python

I would like to read an environment map in *.hdr file format. It seems that very popular libraries doesnt support .hdr file reading, for example, OpenCV, PIL etc.. So how to read a .hdr file into a num…

What is the preferred way to compose a set from multiple lists in Python

I have a few different lists that I want to turn into a set and use to find the difference from another set. Lets call them A, B, and C. Is the more optimal way to do this set(A + B + C) or set(A).unio…

matplotlib plot small image without resampling

Im trying to plot a small image in python using matplotlib and would like the displayed axes to have the same shape as the numpy array it was generated from, i.e. the data should not be resampled. In o…

Nullable ForeignKeys and deleting a referenced model instance

I have a ForeignKey which can be null in my model to model a loose coupling between the models. It looks somewhat like that:class Message(models.Model):sender = models.ForeignKey(User, null=True, blank…

UnrecognizedImageError - image insertion error - python-docx

I am trying to insert an wmf file to docx using python-docx which is producing the following traceback. Traceback (most recent call last):File "C:/Users/ADMIN/PycharmProjects/ppt-to-word/ppt_reade…

Python pool map and choosing number of processes

In setting the number of processes, Id be keen to see how many threads I can actually use on my machine - how do I find this? Is there a way to determine the number of threads available to me?

connection times out when trying to connect to mongodb atlas with python

Im trying to connect to my mongodb atlas cluster but i keep getting timed out as soon as i try to do something with my db. The db i use was created in mongoshell and also the collection i checked their…

Supervisor not working with Gunicorn + Flask

I am trying to run Gunicorn from Supervisor in an Ubuntu 12.04 system. Gunicorn runs a Flask app (simple REST web service tested with Flasks embedded server). I have installed Gunicorn by clonning GIT …

How to hash int/long using hashlib in Python?

Im developing a set of cryptographic algorithms / protocols for educational purposes. Specifically, I am currently working on OAEP encoding.OAEP involves use of cryptographic hash functions; therefore …