Registry / data / pyreadr

pyreadr

JSON →
library0.5.6pypypi✓ verified 85d ago

pyreadr is a Python library designed to read and write R RData and Rds files, seamlessly converting them to and from pandas DataFrames. The current version is 0.5.6. Releases are generally infrequent, often focusing on build system improvements, dependency compatibility, or minor feature additions.

pip install pyreadr
INSTALL
IMPORT
SIG · PYREADR
P
pyreadr
datapythonv0.5.6
Install
7.3s avg
Import
977ms
Disk
161MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 7.6s
py 3.11
✕ build_error
✓ 7.05s
py 3.12
✕ build_error
✓ 7.2s
py 3.13
✕ build_error
✓ 7.4s
py 3.9
✕ build_error
✕ build_error
161MB installed
● package 161MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

read_r
from pyreadr import read_r
import pyreadr; result = pyreadr.read_rdata('file.RData')
write_rdata
from pyreadr import write_rdata
write_rds
from pyreadr import write_rds

This quickstart demonstrates how to write Python data (pandas DataFrame, NumPy array) into RData and Rds files, and then read them back. For RData, the result is a dictionary mapping R object names to Python objects. For Rds (single object), the result is directly the Python object.

import pyreadr import pandas as pd import numpy as np import os # Create a dummy RData file for testing data_for_r = {'df': pd.DataFrame({'col1': [1, 2, 3], 'col2': ['a', 'b', 'c']}), 'vec': np.array([10, 20, 30])} pyreadr.write_rdata("dummy.RData", data_for_r) # Read RData file result_rdata = pyreadr.read_rdata("dummy.RData") # result_rdata is a dictionary where keys are R object names df_from_r = result_rdata['df'] vec_from_r = result_rdata['vec'] # Create a dummy Rds file for testing (single object) df_to_rds = pd.DataFrame({'colA': [10, 20], 'colB': ['x', 'y']}) pyreadr.write_rds(df_to_rds, "dummy.rds") # Read Rds file result_rds = pyreadr.read_rds("dummy.rds") # result_rds is the pandas DataFrame directly df_from_rds = result_rds print("DataFrame from RData:\n", df_from_r) print("Vector from RData:\n", vec_from_r) print("DataFrame from Rds:\n", df_from_rds) # Clean up dummy files os.remove("dummy.RData") os.remove("dummy.rds")
Debug
Known issues
gotchaOn some Linux distributions, `pyreadr`'s underlying C libraries (`librdata`, `libiconv`) might fail to link during installation, leading to `ImportError`. This often happens when `libiconv` development headers are not correctly found.
fix
Try setting the environment variable `PYREADR_LINK_ICONV=1` before installing: `PYREADR_LINK_ICONV=1 pip install pyreadr`. Ensure `libiconv-dev` (or equivalent for your distro) is installed: e.g., `sudo apt-get install libiconv-hook-dev`.
affects: All versions, particularly on Linux.
breaking`pyreadr` versions older than 0.5.5 may not be compatible with pandas 3.0 or newer due to internal changes in pandas. This could lead to various `TypeError` or `AttributeError` exceptions.
fix
Upgrade `pyreadr` to version 0.5.5 or newer: `pip install --upgrade pyreadr`. If using an older pandas version, ensure it's within the range supported by your `pyreadr` version.
affects: <0.5.5
gotchaThe underlying `librdata` library may not support all possible RData/Rds file versions or complex R object types (e.g., S4 objects, environments, specific user-defined types). Attempting to read unsupported structures might result in errors or incomplete data.
fix
If encountering issues with specific R files, try simplifying the R objects before saving them in R. Check the `librdata` documentation for supported R types. For debugging, inspect the `pyreadr.read_rdata(file_path).keys()` to see what objects are successfully parsed.
affects: All versions.
Upgrade
Version history
0.5.6latest on PyPI · released Apr 13, 2026
Audit
Dependencies
pandasrequiredCore data structure for RData/Rds conversion.
Agent activity
7 hits · last 30 days
node
6
Resources
pyreadr — pip install pyreadr · libregistry