Re: couldn't import cairo within python in Mavericks

"Bryce W. Harrington" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On Thu, Jun 26, 2014 at 10:10:37AM -0400, Giancarlo Ruffo wrote:
> Dear all,
> 
> I have this configuration on my MacBook Air:
> 
> OSX Mavericks
> iPython (distribution: Anaconda)
> python 2.7
> igraph packacge installed
> 
> the plot function uses cairo, and I tried to install it.
> 
> Hence, I installed Cairo and Py2Cairo (version: 1.10.0). Everything
> apparently works with the installation. But when I try to execute
> "import cairo" using tests included in your distribution of PyCairo,
> these messages are returned:
> 
> $ py.test
> ============================= test session starts
> ==============================
> platform darwin -- Python 2.7.7 -- py-1.4.20 -- pytest-2.5.2
> collected 0 items / 2 errors
> 
> ==================================== ERRORS
> ====================================
> _________________________ ERROR collecting api_test.py
> _________________________
> api_test.py:12: in <module>
> >  import cairo
> E   ImportError: No module named cairo
> ______________________ ERROR collecting examples_test.py
> _______________________
> examples_test.py:11: in <module>
> >  import cairo
> E   ImportError: No module named cairo
> =========================== 2 error in 0.03 seconds
> ============================
> 
> 
> In fact, I cannot execute the "plot" function within iPython/igraph...
> 
> Can you help me?

Find the directory that you installed pycairo to.

Now verify this is in your python path:

$ python
>>> import sys
>>> print "\n".join(sys.path)

/usr/local/lib/python2.7/dist-packages/coverage-3.6-py2.7-linux-x86_64.egg
/usr/local/lib/python2.7/dist-packages/nose-1.3.0-py2.7.egg
/usr/local/lib/python2.7/dist-packages/vobject-0.8.1c-py2.7.egg
/usr/local/lib/python2.7/dist-packages/Sphinx-1.2.2-py2.7.egg
/usr/local/lib/python2.7/dist-packages/Jinja2-2.7.2-py2.7.egg
/usr/local/lib/python2.7/dist-packages/caldav-0.1.12-py2.7.egg
/usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PIL
/usr/lib/python2.7/dist-packages/gst-0.10
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/pymodules/python2.7
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
/usr/lib/python2.7/dist-packages/ubuntuone-client
/usr/lib/python2.7/dist-packages/ubuntuone-control-panel
/usr/lib/python2.7/dist-packages/ubuntuone-couch
/usr/lib/python2.7/dist-packages/ubuntuone-installer
/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol

If it isn't, then either fix your python installation, or work around it
in your script via something like:

import sys, os.path
sys.path.insert(
    0, os.path.realpath("/my/path/here/"))
import cairo

> Thanks
> Giancarlo Ruffo
> 
> -- 
> cairo mailing list
> [email protected]
> http://lists.cairographics.org/mailman/listinfo/cairo
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.