How to Install cffi in Python

v2.0.0 General Purpose Python >=3.9

Foreign Function Interface for Python calling C code.

Install pip install cffi

What is cffi?

Foreign Function Interface for Python calling C code.

Foreign Function Interface for Python calling C code.

Please see the [Documentation] or uncompiled in the subdirectory.

Source code is publicly available on GitHub.

Quick Start

Minimal example to get started with cffi:

import cffi

print(cffi.__version__)

Installation

pip (standard)

pip install cffi

Virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install cffi

pip3

pip3 install cffi

conda

conda install -c conda-forge cffi

Poetry

poetry add cffi

Dependencies

Installing cffi will also install these packages:

Verify the Installation

After installing, confirm the package is available:

python -c "import cffi; print(cffi.__version__)"

If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.

Installation Errors

Common errors when installing cffi with pip.

ModuleNotFoundError: No module named 'cffi'

Cause: The package is not installed in the current Python environment.

Fix: Run pip install cffi. If using a virtual environment, ensure it is activated first.

ModuleNotFoundError: No module named 'cffi' (installed but still failing)

Cause: pip installed the package into a different Python than the one running your script.

Fix: Use python -m pip install cffi to install into the interpreter you are running.

ImportError: cannot import name 'X' from 'cffi'

Cause: The function or class does not exist in the installed version.

Fix: Check the version with pip show cffi and upgrade with pip install --upgrade cffi.

pip: command not found

Cause: pip is not in PATH or Python was not added to PATH during installation.

Fix: Try python -m pip install cffi. On macOS/Linux try pip3.

PermissionError: [Errno 13] Permission denied

Cause: No write access to the system Python package directory.

Fix: Use a virtual environment, or add --user: pip install --user cffi

SSL: CERTIFICATE_VERIFY_FAILED

Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.

Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org cffi

Recent Releases

VersionReleased
2.0.0 latest 2025-09-08
2.0.0b1 2025-07-29
1.17.1 2024-09-04
1.17.0 2024-08-06
1.17.0rc1 2024-05-23

Full release history on PyPI →

Manage cffi

Upgrade to latest version

pip install --upgrade cffi

Install a specific version

pip install cffi==2.0.0

Uninstall

pip uninstall cffi

Check what is installed

pip show cffi

Last updated: 2026-04-11 • Data from PyPI