HenriquesLab / HenriquesLab/ZeroCostDL4Mic

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

Open
#348 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
652
Forks
144
PR merge metrics
No merged PRs in 30d

Description

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!


Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file or test is named; start by reproducing the listed imports in a Google Colab environment with the stated Python, NumPy, csbdeep, and stardist versions. Compare the dependency constraints and determine whether a supported version combination can be documented, with an environment YAML or explicit compatibility guidance as the completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python, tensorflow
Domain
cloud, machine-learning
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.