rpy2
Python interface to the R language (embedded R)
What it is and what it does
rpy2 is a Python-to-R bridge that embeds an R interpreter within Python, letting you execute R code and manipulate R objects from Python without spawning a separate process. It wraps R's C API through rpy2-rinterface and provides high-level object bindings via rpy2-robjects, making it possible to mix R's statistical and data-manipulation capabilities directly into Python workflows.
The package is designed for data scientists and researchers who need R's specialized libraries but want to work within a Python environment. It requires R to be installed on your system and handles the bridging between Python and R's runtime, including memory management and type conversion. Installation is straightforward for standard setups, though non-standard R installations may require environment configuration.
Use it for:
- Call R statistical functions and models from Python without leaving your Python environment or data pipeline.
- Use R's specialized packages to process or visualize data already in Python.
- Prototype data analysis workflows that combine Python libraries with R capabilities in a single script.
- Convert between Python objects and R objects for interoperability.
- Embed R computations in Python applications where R's domain expertise is needed but Python is the primary language.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
rpy2 embeds R within Python, allowing you to call R functions and work with R objects directly from Python code without launching a separate R process.
Yes, if you need R's capabilities within Python and your project can accept GPL-2.0-or-later licensing. The package is actively maintained, has low install friction (wheel available), and works with modern Python versions (3.9 through 3.13). Not suitable for proprietary projects due to copyleft licensing. Requires R to be installed separately on your system.
Install
rpy2 on PyPI
pip
pip install rpy2uv
uv add rpy2poetry
poetry add rpy2Installing rpy2
Before you install
Low friction: pure Python wheel available. Requires R to be installed on your system and accessible in PATH; if R is in a non-standard location, you may need to set LD_LIBRARY_PATH before importing. Active maintenance with recent releases.
License in practice
GPL-2.0-or-later (copyleft): any code that links rpy2 must be distributed under GPL-2.0 or later. Proprietary or permissively-licensed projects cannot use this package without accepting copyleft obligations.
Quickstart
pip install rpy2
from rpy2.robjects import r
result = r('some_r_code')
R must be installed and in your system PATH; rpy2-rinterface (a compiled C extension) requires a working R installation with accessible shared libraries.
Verify before relying
- Whether optional dependencies (numpy, pandas, ipython) are needed for typical workflows or only for specific use cases.
- Performance characteristics when calling R functions repeatedly from Python in tight loops.
Package facts
| License | GPL-2.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — rpy2-rinterface, rpy2-robjects, packaging |
| Maintenance | actively maintained — 140 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 385,556/month — #7,061 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: rpy2-3.6.7-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
rpy2-rinterfacerpy2-rinterface provides a low-level…
copyleft · top 15,000 on PyPI
rpy2-robjectsProvides a Python interface to call R code and…
copyleft · top 15,000 on PyPI
jupyterJupyter is a metapackage that installs the core…
permissive · top 5,000 on PyPI
jupyter-sphinxJupyter Sphinx Extensions runs code embedded in…
unclear · top 15,000 on PyPI
pylink-squareProvides a Python interface to control SEGGER…
permissive · top 5,000 on PyPI
mpi4pympi4py provides Python bindings for the Message…
permissive · top 5,000 on PyPI
widgetsnbextensionProvides the JavaScript frontend and…
permissive · top 1,000 on PyPI
astevalAsteval is a safe Python expression and…
permissive · top 5,000 on PyPI
princePrince implements multivariate exploratory data…
permissive · top 15,000 on PyPI
pyreadrReads and writes R RData and Rds files directly…
agpl · top 15,000 on PyPI