I get the following error when trying to import gtk in Python 2.7 :
>>> import gtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "gtk/__init__.py", line 40, in <module>
from gtk import _gtk
File "/usr/lib/python2.7/site-packages/cairo/__init__.py", line 1, in <module>
from ._cairo import * # noqa: F401,F403
ImportError: /usr/lib/python2.7/site-packages/cairo/_cairo.so: undefined symbol: cairo_tee_surface_index
And I get the following error when trying to import cairo from Python 3.6:
>>> import cairo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/site-packages/cairo/__init__.py", line 1, in <module>
from ._cairo import * # noqa: F401,F403
ImportError: /usr/lib/python3.6/site-packages/cairo/_cairo.cpython-36m-x86_64-linux-gnu.so: undefined symbol: cairo_tee_surface_index
I compiled and built the modules in the order as given in the BLFS book. I also installed cairo as given in the book with tee enabled.
My system is an LFS, with 4.14.4 Kernel Version, with Python 2.7.14 and Python 3.6.4.
EDIT: Downloaded the source and did 'make uninstall' and then reinstalled it. Now I can import cairo without any errors.