Skip to content

Python API: .to_df() segfaults when NumPy is installed but Pandas is missing #16339

@nodakai

Description

@nodakai

What happens?

Calling .to_df() in the Python API causes a segmentation fault if NumPy is installed but Pandas is not. Ideally, the function should raise a clear error indicating that Pandas is required.

To Reproduce

% uv venv venv
Using CPython 3.13.2 interpreter at: /usr/bin/python3
Creating virtual environment at: venv
Activate with: source venv/bin/activate
% . venv/bin/activate
% uv pip install duckdb numpy
Using Python 3.13.2 environment at: venv
Resolved 2 packages in 24ms
Installed 2 packages in 16ms
 + duckdb==1.2.0
 + numpy==2.2.3
% python3
Python 3.13.2 (main, Feb  5 2025, 01:23:35) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import duckdb
>>> r = duckdb.read_csv('/etc/hostname')
>>> r.to_df()
zsh: segmentation fault  python3
% python3
Python 3.12.8 (main, Dec  3 2024, 18:42:41) [Clang 16.0.0 (clang-1600.0.26.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import duckdb
>>> r = duckdb.read_csv('/etc/xtab')
>>> r.to_df()
zsh: segmentation fault  python3

OS:

Debian Linux testing aarch64, macOS Sonama 14.6.1 M3 Pro

DuckDB Version:

1.2.0

DuckDB Client:

Python

Hardware:

No response

Full Name:

NODA Kai

Affiliation:

Independent

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions