Opened 7 years ago

Closed 5 years ago

#50785 closed defect (fixed)

py27-cairosvg: AttributeError: 'module' object has no attribute 'ANTIALIAS_FAST'

Reported by: DanielO (Daniel O'Connor) Owned by: seanfarley (Sean Farley)
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: Cc:
Port: py27-cairosvg

Description (last modified by ryandesign (Ryan Schmidt))

In [20]: import cairosvg
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-20-8605454d1a82> in <module>()
----> 1 import cairosvg

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cairosvg/__init__.py in <module>()
     25 import optparse
     26
---> 27 from . import surface
     28
     29

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cairosvg/surface/__init__.py in <module>()
     45
     46 SHAPE_ANTIALIAS = {
---> 47     "optimizeSpeed": cairo.ANTIALIAS_FAST,
     48     "crispEdges": cairo.ANTIALIAS_NONE,
     49     "geometricPrecision": cairo.ANTIALIAS_BEST}

AttributeError: 'module' object has no attribute 'ANTIALIAS_FAST'

I worked around this by modifying /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/cairosvg/surface/__init__.py and adding the following after the import statements

cairo.ANTIALIAS_FAST = cairo.ANTIALIAS_NONE
cairo.ANTIALIAS_GOOD = cairo.ANTIALIAS_SUBPIXEL
cairo.ANTIALIAS_BEST = cairo.ANTIALIAS_SUBPIXEL

Change History (5)

comment:1 Changed 7 years ago by DanielO (Daniel O'Connor)

Never mind, it's not actually a python SVG library! Note to self: read documentation first.

comment:2 Changed 7 years ago by ryandesign (Ryan Schmidt)

Description: modified (diff)
Owner: changed from macports-tickets@… to sean@…
Summary: Can't import py27-cairosvgpy27-cairosvg: AttributeError: 'module' object has no attribute 'ANTIALIAS_FAST'

comment:3 Changed 7 years ago by seanfarley (Sean Farley)

Huh. I can reproduce this easily. Will investigate.

comment:4 Changed 7 years ago by pavel+ports@…

hi,

have the same error on OS X 10.9.5, Python 2.7.5

my script:

Traceback (most recent call last):
  File "process.py", line 111, in <module>
    main()
  File "process.py", line 106, in main
    print _draw_graph(result, "%s.svg" % "report1")
  File "process.py", line 43, in _draw_graph
    raise e
AttributeError: 'module' object has no attribute 'ANTIALIAS_FAST'
$ cairosvg -V
Traceback (most recent call last):
  File "/usr/local/bin/cairosvg", line 24, in <module>
    import cairosvg
  File "/Library/Python/2.7/site-packages/cairosvg/__init__.py", line 27, in <module>
    from . import surface
  File "/Library/Python/2.7/site-packages/cairosvg/surface/__init__.py", line 47, in <module>
    "optimizeSpeed": cairo.ANTIALIAS_FAST,
AttributeError: 'module' object has no attribute 'ANTIALIAS_FAST'
$ sudo port info cairo | head  -1
cairo @1.14.6 (graphics)

comment:5 Changed 5 years ago by seanfarley (Sean Farley)

Resolution: fixed
Status: newclosed

I'm pretty sure this was either 'invalid' or fixed in the meantime. Feel free to re-open if that's not the case.

Note: See TracTickets for help on using tickets.