skillfed

rpy2

Python interface to the R language (embedded R)

rpy2 v3.6.7 385.6K downloads/30d#7,061 on PyPI702
Copyleft license GPL-2.0-or-later Active released

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 rpy2

uv

uv add rpy2

poetry

poetry add rpy2

Installing 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

Intended Audience :: DevelopersIntended Audience :: Science/ResearchProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9

Tags

python r integrationcall r from pythonembedded r interpreterpython r bridger language bindingsdataframe r pythonstatistical computing python
statistical-computinglanguage-interopdata-science

More Scientific/Engineering packages