Skip to content

Compatibility Issue with NumPy 2.x (Import Error) #260

@danielvoconnor

Description

@danielvoconnor

Hi toppra maintainers,

I’m encountering an issue when trying to use toppra with NumPy 2.2.2, and I’d like to ask about potential support for NumPy 2.x or any recommended workarounds.

Problem
After installing toppra via pip in a Python 3.12 virtual environment, I get an error when running import toppra. The error suggests a compatibility issue between NumPy 2.2.2 and toppra, which was compiled with NumPy 1.x. Here’s the full traceback:

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.2 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):
File "", line 1, in
File "/Users/doconnor/Dropbox/USF_teaching/Spring2025/MATH373/my_venv/lib/python3.12/site-packages/toppra/init.py", line 16, in
from . import constraint
File "/Users/doconnor/Dropbox/USF_teaching/Spring2025/MATH373/my_venv/lib/python3.12/site-packages/toppra/constraint/init.py", line 83, in
from .linear_joint_velocity import (
File "/Users/doconnor/Dropbox/USF_teaching/Spring2025/MATH373/my_venv/lib/python3.12/site-packages/toppra/constraint/linear_joint_velocity.py", line 3, in
from toppra._CythonUtils import (_create_velocity_constraint,
File "toppra/_CythonUtils.pyx", line 1, in init toppra._CythonUtils
ImportError: numpy.core.multiarray failed to import

Environment

  • Python version: 3.12
  • NumPy version: 2.2.2
  • toppra version: 0.6.2
  • OS: macOS

Steps to Reproduce

  1. Create a Python 3.12 virtual environment
  2. Install NumPy 2.2.2 (pip install numpy==2.2.2)
  3. Install toppra (pip install toppra)
  4. Run import toppra in Python.

Current Workaround
Downgrading to numpy<2.0 (e.g., pip install "numpy<2.0") resolves the issue, but I’d prefer to use a newer NumPy version if possible.

Request

  • Is there a plan to update toppra to support NumPy 2.x?
  • If not, are there recommended workarounds besides downgrading NumPy (e.g., rebuilding from source)?
  • Any guidance would be appreciated!

Thanks for maintaining this great library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions