Skip to content

ImportError: numpy.core.multiarray failed to import #1680

Closed
@lbaliunas

Description

@lbaliunas

Describe the bug

ImportError with cv2 and numpy when using labelbox.
Stack trace:

    from labelbox.data.annotation_types import ImageData, Label
/usr/local/lib/python3.11/site-packages/labelbox/data/annotation_types/__init__.py:1: in <module>
    from .geometry import Line
/usr/local/lib/python3.11/site-packages/labelbox/data/annotation_types/geometry/__init__.py:1: in <module>
    from .line import Line
/usr/local/lib/python3.11/site-packages/labelbox/data/annotation_types/geometry/line.py:5: in <module>
    import cv2
E   ImportError: numpy.core.multiarray failed to import

Also:

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 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.

To reproduce

Steps to reproduce the behavior:

  1. Run from labelbox.data.annotation_types import ImageData, Label

Environment (please complete the following information

  • OS: macOS Sonoma 14.5
  • Python Version: 3.11.8
  • SDK + SDK Version: labelbox[data]==3.67.0

Additional context

I believe the required fix should be to set the numpy optional dependency to numpy>=1.24.4,<2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions