Skip to content

ImportError: numpy.core.multiarray failed to import / AttributeError: _ARRAY_API not found` when importing stardist #348

@pchegom

Description

@pchegom

Hi, I'm running into persistent import errors when trying to use stardist in a Colab environment. Even after reinstalling dependencies carefully, I still encounter the following:


Error Tracebacks:

ImportError: numpy.core.multiarray failed to import
AttributeError: _ARRAY_API not found
ModuleNotFoundError: No module named 'stardist'

These occur especially when importing from:

from stardist.utils import fill_label_holes, random_label_cmap, calculate_extents, gputools_available

What I've Tried:

  1. Uninstalled and reinstalled packages with pinned versions:

    pip uninstall -y stardist csbdeep gputools
    pip install numpy==1.23.5
    pip install csbdeep==0.7.2
    pip install --no-build-isolation --no-cache-dir stardist==0.8.3
  2. Restarted the Colab runtime.

  3. Attempted with and without TensorFlow (tensorflow==2.15).

  4. Tried forcing reinstall of numpy with different versions (1.24.x, 1.23.5, 1.26.x, etc.)


Observation:

I suspect the issue is due to conflicting NumPy version requirements between stardist and other dependencies (e.g. csbdeep, scikit-image, etc.). Some packages internally install a newer version of numpy, causing stardist to break at import due to binary incompatibility (e.g., missing _ARRAY_API or failure in multiarray).


Environment:

  • Platform: Google Colab
  • Python: 3.11.8
  • numpy: 1.23.5 (tried other versions too)
  • csbdeep: 0.7.2
  • stardist: 0.8.3

Request:

Is there a known compatible set of versions for stardist, csbdeep, and numpy for Python 3.11? Alternatively, should I downgrade to an older Python version (e.g. 3.9) to avoid these conflicts? Any guidance or environment YAML would be very helpful.

Thanks in advance for your support!


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