Failed to install "Cairocffi"

13,609

Solution 1

My problem is fixed by installing a specific version of cairocffi (version = 0.6)

pip install cairocffi==0.6

Solution 2

I ran into this today as well. Are you working through the Real Python course?

Anyway, to fix the problem, I installed the python 3 version of python-dev:

sudo apt-get install python3-dev
sudo apt-get install libffi-dev
sudo pip3 install cffi
sudo pip3 install cairocffi

Hope this helps!

Solution 3

install the libffi-dev package can fix this problem simply run sudo apt install libffi-dev

Share:
13,609
Sam
Author by

Sam

I'm a software engineer. I started programming with C#, then moved to learn and develop with python language, especially the Django Framework. Since that, i've worked with new web development technologies. I try to share what i know about programming.

Updated on June 12, 2022

Comments

  • Sam
    Sam almost 2 years

    I'm working with python3, and i'm trying to install " cairocffi" on Ubuntu. To do this, i've successfully installed:

    1. python-dev
    2. libffi-dev
    3. cffi

    But when i've trying to install "cairocffi" with pip install cairocffi,I got:

          File "/usr/local/lib/python3.2/dist-packages/setuptools/dist.py", line 272
    , in __init__
            _Distribution.__init__(self,attrs)
          File "/usr/lib/python3.2/distutils/dist.py", line 261, in __init__
            self.finalize_options()
          File "/usr/local/lib/python3.2/dist-packages/setuptools/dist.py", line 327
    , in finalize_options
            ep.load()(self, ep.name, value)
          File "/usr/local/lib/python3.2/dist-packages/cffi/setuptools_ext.py", line
     161, in cffi_modules
            add_cffi_module(dist, cffi_module)
          File "/usr/local/lib/python3.2/dist-packages/cffi/setuptools_ext.py", line
     48, in add_cffi_module
            execfile(build_file_name, mod_vars)
          File "/usr/local/lib/python3.2/dist-packages/cffi/setuptools_ext.py", line
     24, in execfile
            exec(code, glob, glob)
          File "cairocffi/ffi_build.py", line 30, in <module>
            ffi.cdef(constants._CAIRO_HEADERS)
        AttributeError: 'module' object has no attribute '_CAIRO_HEADERS'
    
        ----------------------------------------
        Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-y0b_ir/cairocffi
    
    • J.J. Hakala
      J.J. Hakala about 8 years
      The location of file /usr/local/lib/python3.2/dist-packages/setuptools/dist.py is odd. At the same time there is /usr/lib/python3.2/distutils/dist.py so I guess you have installed python3 ubuntu package but not python3-setuptools, and then setuptools in some other way. I tried to replicate your problem with xubuntu 12.04, there were no installation problems.
  • danijar
    danijar over 7 years
    @zumma It did for me.
  • Erwol
    Erwol about 6 years
    This fixs the issue when installing CairoSVG 2.1.3 in ubuntu 16.04
  • davesave
    davesave almost 5 years
    i also add: "python3-cffi libcairo2"
  • Matthew Schinckel
    Matthew Schinckel over 3 years
    Well, that's all well and good, except I need 0.9.0... which still seems to give a similar error to this question.