Skip to content

AttributeError: module 'cffi' has no attribute 'FFI' in version 2.0.0 #222

@map0logo

Description

@map0logo

Description:

After upgrading to cffi v2.0.0, downstream libraries (notably statsmodels) are failing because cffi.FFI is no longer accessible as a top-level attribute of the cffi module.

In version 1.x, it was standard to initialize the interface via cffi.FFI(). In v2.0.0, this now raises an AttributeError.

We are seeking clarification on whether this is an intentional breaking change for the 2.0.0 roadmap (requiring downstream updates) or an unintended packaging/export issue.

Environment:

  • cffi version: 2.0.0
  • Python version: 3.12
  • OS: Manjaro Linux

Steps to Reproduce:

import cffi
print(f"CFFI Version: {cffi.__version__}")

# This worked in 1.17.x, but fails in 2.0.0
try:
    ffi = cffi.FFI()
    print("Successfully initialized FFI")
except AttributeError as e:
    print(f"Error: {e}")

Observed Behavior:

CFFI Version: 2.0.0
Error: module 'cffi' has no attribute 'FFI'

Impact:

This currently breaks statsmodels.stats.multicomp.pairwise_tukeyhsd, which is widely used in the scientific Python ecosystem (often within JupyterLab environments where cffi is a transitive dependency).

Traceback from statsmodels:

File ".../statsmodels/stats/multicomp.py", line 123, in pairwise_tukeyhsd
    ffi = cffi.FFI()
AttributeError: module 'cffi' has no attribute 'FFI'

Questions:

  1. Is cffi.FFI intentionally moved or removed in v2.0.0?
  2. Is there a new recommended way to instantiate the FFI object (e.g., a specific sub-module import)?
  3. Should downstream maintainers pin cffi < 2.0.0 for compatibility?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions