Skip to content

Support Numpy 2.0 #1558

@MalteEbner

Description

@MalteEbner

Error using lightly with numpy 2.0

Numpy 2.0.0 was released on June 16th 2024 and does not work with lightly.

Using numpy==2.0.0 and lightly==1.5.6 and python==3.10.8:

(.venv) user@device repo % python -c "import lightly"                           
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/malteebnerlightly/Documents/GitHub/lightspeed/.venv/lib/python3.10/site-packages/lightly/__init__.py", line 88, in <module>
    from lightly.api import _version_checking
  File "/Users/malteebnerlightly/Documents/GitHub/lightspeed/.venv/lib/python3.10/site-packages/lightly/api/__init__.py", line 7, in <module>
    from lightly.api.api_workflow_client import ApiWorkflowClient
  File "/Users/malteebnerlightly/Documents/GitHub/lightspeed/.venv/lib/python3.10/site-packages/lightly/api/api_workflow_client.py", line 21, in <module>
    from lightly.api.api_workflow_selection import _SelectionMixin
  File "/Users/malteebnerlightly/Documents/GitHub/lightspeed/.venv/lib/python3.10/site-packages/lightly/api/api_workflow_selection.py", line 30, in <module>
    class _SelectionMixin:
  File "/Users/malteebnerlightly/Documents/GitHub/lightspeed/.venv/lib/python3.10/site-packages/lightly/api/api_workflow_selection.py", line 32, in _SelectionMixin
    self, al_scores: Dict[str, NDArray[np.float_]], query_tag_id: str
  File "/Users/malteebnerlightly/Documents/GitHub/lightspeed/.venv/lib/python3.10/site-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.float_` was removed in the NumPy 2.0 release. Use `np.float64` instead.. Did you mean: 'float16'?

Reproduce

Run in a new venv, such that numpy 2.0 is installed:

pip install lightly 
python -c "import lightly"  

Workaround

Just install an older numpy version, e.g. using pip install numpy==1.26.

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