Discussion:
[cairo] PyCairo on Mac OS X
Elver Loho
2010-04-17 22:54:16 UTC
Permalink
Hi!

I'm trying to install PyCairo on Mac OS X. Or, rather, I've done it.
But it doesn't work.
I've installed Cairo with Mac Ports. I've installed PyCairo with easy_install.
This is what happens when I try to use it:

YellowTracksuit:~ elver$ python
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import cairo
dir(cairo)
['__builtins__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__']
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 256, 256)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ImageSurface'

There be nothing there! What could be wrong and how do I fix it?

Best,
Elver

elver.loho at gmail.com
+372 5661 6933
http://elver.wordpress.com/
skype: elver.loho
Dane Springmeyer
2010-04-18 21:31:01 UTC
Permalink
Did you accidentally name some python file 'cairo.py' that is also on
your import path?

To confirm that '>>> import cairo' is really getting the pycairo
module find the path to it:

import cairo
cairo.__file__

and make sure that points to the right thing (a cairo directory with
an __init__.py and _cairo.so file within it).

Dane
Post by Elver Loho
Hi!
I'm trying to install PyCairo on Mac OS X. Or, rather, I've done it.
But it doesn't work.
I've installed Cairo with Mac Ports. I've installed PyCairo with easy_install.
YellowTracksuit:~ elver$ python
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import cairo
dir(cairo)
['__builtins__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__']
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 256, 256)
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ImageSurface'
There be nothing there! What could be wrong and how do I fix it?
Best,
Elver
elver.loho at gmail.com
+372 5661 6933
http://elver.wordpress.com/
skype: elver.loho
--
cairo mailing list
cairo at cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo
Elver Loho
2010-04-19 14:38:39 UTC
Permalink
It would appear that I've not named anything cairo.py by accident, but
that was a good guess -- I've had that problem before :)

YellowTracksuit:src elver$ python
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Post by Elver Loho
import cairo
dir(cairo)
['__builtins__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__']
Post by Elver Loho
cairo.__file__
'/Library/Python/2.6/site-packages/pycairo-1.8.8-py2.6-macosx-10.6-universal.egg/cairo/__init__.pyc'

Best,
Elver

elver.loho at gmail.com
+372 5661 6933
http://elver.wordpress.com/
skype: elver.loho
Did you accidentally name some python file 'cairo.py' that is also on your
import path?
To confirm that '>>> import cairo' is really getting the pycairo module find
import cairo
cairo.__file__
and make sure that points to the right thing (a cairo directory with an
__init__.py and _cairo.so file within it).
Dane
Post by Elver Loho
Hi!
I'm trying to install PyCairo on Mac OS X. Or, rather, I've done it.
But it doesn't work.
I've installed Cairo with Mac Ports. I've installed PyCairo with easy_install.
YellowTracksuit:~ elver$ python
Python 2.6.1 (r261:67515, Jul ?7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import cairo
dir(cairo)
['__builtins__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__']
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 256, 256)
?File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ImageSurface'
There be nothing there! What could be wrong and how do I fix it?
Best,
Elver
elver.loho at gmail.com
+372 5661 6933
http://elver.wordpress.com/
skype: elver.loho
--
cairo mailing list
cairo at cairographics.org
http://lists.cairographics.org/mailman/listinfo/cairo
Andrew Dalke
2010-04-30 10:24:33 UTC
Permalink
Post by Elver Loho
I've installed Cairo with Mac Ports. I've installed PyCairo with easy_install.
...
Post by Elver Loho
AttributeError: 'module' object has no attribute 'ImageSurface'
...
Post by Elver Loho
Post by Dane Springmeyer
cairo.__file__
'/Library/Python/2.6/site-packages/pycairo-1.8.8-py2.6-macosx-10.6-
universal.egg/cairo/__init__.pyc'

I have the same problem, also with a MacPorts installation of cairo. I want
to use the system Python though, and not the MacPorts-installed one.
Post by Elver Loho
import cairo
cairo.__file__
'/Library/Python/2.6/site-packages/
pycairo-1.8.8-py2.6-macosx-10.6-universal.egg/cairo/__init__.pyc'
Post by Elver Loho
cairo.ImageSurface
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ImageSurface'
Post by Elver Loho
import cairo._cairo
cairo.ImageSurface
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'ImageSurface'
Post by Elver Loho
cairo._cairo.ImageSurface
<type 'cairo.ImageSurface'>
Post by Elver Loho
cairo._cairo.version
'1.8.8'
% unzip -l '/Library/Python/2.6/site-packages/
pycairo-1.8.8-py2.6-macosx-10.6-universal.egg'
Archive: /Library/Python/2.6/site-packages/
pycairo-1.8.8-py2.6-macosx-10.6-universal.egg
Length Date Time Name
-------- ---- ---- ----
55 04-30-10 10:39 cairo/__init__.py
229 04-30-10 10:39 cairo/__init__.pyc
276 04-30-10 10:39 cairo/_cairo.py
554 04-30-10 10:39 cairo/_cairo.pyc
353096 04-30-10 10:39 cairo/_cairo.so
1 04-30-10 10:39 EGG-INFO/dependency_links.txt
16 04-30-10 10:39 EGG-INFO/native_libs.txt
200 04-30-10 10:39 EGG-INFO/PKG-INFO
234 04-30-10 10:39 EGG-INFO/SOURCES.txt
6 04-30-10 10:39 EGG-INFO/top_level.txt
1 04-30-10 10:39 EGG-INFO/zip-safe
7129 08-26-09 12:59 include/pycairo/pycairo.h
191 04-30-10 10:39 lib/pkgconfig/pycairo.pc
-------- -------
361988 13 files


I looked into it a bit but ran into the confusion that setuptools
almost always gives me.

-- Andrew Dalke <dalke at dalkescientific.com>
Andrew Dalke
2010-04-30 12:26:33 UTC
Permalink
While building the last version from git works.

Best regards,

-- Andrew Dalke <dalke at dalkescientific.com>

Loading...