cairocffi: Document installation for OSX (cannot import name constants)
I am trying to install Graphite. I am stuck upon cairo installation. I came across “http://stackoverflow.com/questions/11491268/install-pycairo-in-virtualenv”. I have installed cairocffi in my virtual environment.
My environment is: “OS X: 10.8.5 Python: 2.7.2 Virtual Env: pip list cairocffi (0.5.1) ceres (0.10.0) cffi (0.8.1) Django (1.5.5) django-tagging (0.3.1) pip (1.5) pycparser (2.10) setuptools (2.0.2) Twisted (11.1.0) txAMQP (0.6.2) whisper (0.9.12) wsgiref (0.1.2) zope.interface (4.0.5)”
Cairo: I have installed cairo using macports. “cairo @1.12.16_2+x11 (active)”
I started graphite with following sequence of commands:
- source /opt/graphite/bin/activate
- sudo /opt/graphite/bin/carbon-cache.py start
- sudo ./bin/run-graphite-devel-server.py /opt/graphite
http://0.0.0.0:8080/ is displaying Graphite home page. But http://0.0.0.0:8080/render produces following traceback:
Traceback (most recent call last):
File "/opt/graphite/lib/python2.7/site-packages/django/core/handlers/base.py", line 103, in get_response
resolver_match = resolver.resolve(request.path_info)
File "/opt/graphite/lib/python2.7/site-packages/django/core/urlresolvers.py", line 321, in resolve
sub_match = pattern.resolve(new_path)
File "/opt/graphite/lib/python2.7/site-packages/django/core/urlresolvers.py", line 321, in resolve
sub_match = pattern.resolve(new_path)
File "/opt/graphite/lib/python2.7/site-packages/django/core/urlresolvers.py", line 223, in resolve
return ResolverMatch(self.callback, args, kwargs, self.name)
File "/opt/graphite/lib/python2.7/site-packages/django/core/urlresolvers.py", line 230, in callback
self._callback = get_callable(self._callback_str)
File "/opt/graphite/lib/python2.7/site-packages/django/utils/functional.py", line 31, in wrapper
result = func(*args)
File "/opt/graphite/lib/python2.7/site-packages/django/core/urlresolvers.py", line 97, in get_callable
mod = import_module(mod_name)
File "/opt/graphite/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/opt/graphite/webapp/graphite/render/views.py", line 36, in <module>
from graphite.render.evaluator import evaluateTarget
File "/opt/graphite/webapp/graphite/render/evaluator.py", line 47, in <module>
from graphite.render.functions import SeriesFunctions
File "/opt/graphite/webapp/graphite/render/functions.py", line 33, in <module>
from graphite.render.glyph import format_units
File "/opt/graphite/webapp/graphite/render/glyph.py", line 15, in <module>
import cairocffi as cairo
File "/opt/graphite/lib/python2.7/site-packages/cairocffi/__init__.py", line 16, in <module>
from . import constants
ImportError: cannot import name constants
About this issue
- Original URL
- State: open
- Created 10 years ago
- Comments: 39 (15 by maintainers)
I don’t know why, but
apt-get install python-cairo-devfixed my issue (same as OP)Thanks for the answer all above, I met this problem yesterday. By reading your answers, it solved by "brew install cairo"finnally lol
In the version of cairocffi that I got from pip, the code in init.py never uses any of the cairo constants defined in constants.py directly, instead it uses
This can work if the module itself has been imported in the current namespace under the name constants, as is the case with:
but it cannot work if the constants contained in the module have been imported in the current namespace directly as is the case with:
I installed cairocffi from pip on MacOS 10.6.8, using a python-anaconda distribution and got the same error as the original poster:
Changing
to
in the init.py of cairocffi fixed the issue for me.