Import scirpy v0.19.0 failing due to numpy error

For various reasons, I had to recreate this env in a different setting. v0.18.0 mostly worked for me, apart from a previous issue

A fix was provided, but then I couldn’t import pandas or scirpy. I tried to recreate the conda environment as below, but the same ValueError persists

Code tried:

import scirpy

Error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/nsaw/.local/lib/python3.11/site-packages/scirpy/__init__.py", line 3, in <module>
    from . import datasets, get, io, ir_dist, pl, pp, tl, util
  File "/home/nsaw/.local/lib/python3.11/site-packages/scirpy/datasets/__init__.py", line 13, in <module>
    import mudata
  File "/home/nsaw/.local/lib/python3.11/site-packages/mudata/__init__.py", line 13, in <module>
    from anndata import AnnData
  File "/home/nsaw/.local/lib/python3.11/site-packages/anndata/__init__.py", line 29, in <module>
    from ._core.anndata import AnnData
  File "/home/nsaw/.local/lib/python3.11/site-packages/anndata/_core/anndata.py", line 18, in <module>
    import pandas as pd
  File "/home/nsaw/.local/lib/python3.11/site-packages/pandas/__init__.py", line 22, in <module>
    from pandas.compat import is_numpy_dev as _is_numpy_dev  # pyright: ignore # noqa:F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/nsaw/.local/lib/python3.11/site-packages/pandas/compat/__init__.py", line 25, in <module>
    from pandas.compat.numpy import (
  File "/home/nsaw/.local/lib/python3.11/site-packages/pandas/compat/numpy/__init__.py", line 4, in <module>
    from pandas.util.version import Version
  File "/home/nsaw/.local/lib/python3.11/site-packages/pandas/util/__init__.py", line 2, in <module>
    from pandas.util._decorators import (  # noqa:F401
  File "/home/nsaw/.local/lib/python3.11/site-packages/pandas/util/_decorators.py", line 14, in <module>
    from pandas._libs.properties import cache_readonly
  File "/home/nsaw/.local/lib/python3.11/site-packages/pandas/_libs/__init__.py", line 13, in <module>
    from pandas._libs.interval import Interval
  File "pandas/_libs/interval.pyx", line 1, in init pandas._libs.interval
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Conda installation code:

conda create -n scirpy python=3.11 -y
conda activate scirpy
pip install git+https://github.com/scverse/scirpy.git@main 

Output from conda env export:

name: scirpy
channels:
  - conda-forge
  - bioconda
  - defaults
dependencies:
  - _libgcc_mutex=0.1=conda_forge
  - _openmp_mutex=4.5=2_gnu
  - _x86_64-microarch-level=3=2_haswell
  - adjusttext=1.3.0=pyhd8ed1ab_0
  - airr=1.5.1=pyh7cba7a3_0
  - anndata=0.11.0=pyhff2d567_1
  - arpack=3.9.1=nompi_h77f6705_101
  - array-api-compat=1.9.1=pyhd8ed1ab_0
  - awkward=2.7.0=pyhff2d567_0
  - awkward-cpp=41=py311hf8c1401_300
  - brotli=1.1.0=hb9d3cd8_2
  - brotli-bin=1.1.0=hb9d3cd8_2
  - brotli-python=1.1.0=py311hfdbb021_2
  - bzip2=1.0.8=h4bc722e_7
  - c-ares=1.32.3=h4bc722e_0
  - ca-certificates=2024.8.30=hbcca054_0
  - cached-property=1.5.2=hd8ed1ab_1
  - cached_property=1.5.2=pyha770c72_1
  - certifi=2024.8.30=pyhd8ed1ab_0
  - cffi=1.17.1=py311hf29c0ef_0
  - charset-normalizer=3.4.0=pyhd8ed1ab_0
  - colorama=0.4.6=pyhd8ed1ab_0
  - contourpy=1.3.0=py311hd18a35c_2
  - cycler=0.12.1=pyhd8ed1ab_0
  - exceptiongroup=1.2.2=pyhd8ed1ab_0
  - fonttools=4.54.1=py311h2dc5d0c_1
  - freetype=2.12.1=h267a509_2
  - fsspec=2024.10.0=pyhff2d567_0
  - get-annotations=0.1.2=pyhd8ed1ab_0
  - glpk=5.0=h445213a_0
  - gmp=6.3.0=hac33072_2
  - h2=4.1.0=pyhd8ed1ab_0
  - h5py=3.12.1=nompi_py311hb639ac4_102
  - hdf5=1.14.3=nompi_hdf9ad27_105
  - hpack=4.0.0=pyh9f0ad1d_0
  - hyperframe=6.0.1=pyhd8ed1ab_0
  - idna=3.10=pyhd8ed1ab_0
  - importlib-metadata=8.5.0=pyha770c72_0
  - joblib=1.4.2=pyhd8ed1ab_0
  - keyutils=1.6.1=h166bdaf_0
  - kiwisolver=1.4.7=py311hd18a35c_0
  - krb5=1.21.3=h659f571_0
  - lcms2=2.16=hb7c19ff_0
  - ld_impl_linux-64=2.43=h712a8e2_2
  - legacy-api-wrap=1.4=pyhd8ed1ab_1
  - lerc=4.0.0=h27087fc_0
  - levenshtein=0.26.1=py311hfdbb021_0
  - libaec=1.1.3=h59595ed_0
  - libblas=3.9.0=25_linux64_openblas
  - libbrotlicommon=1.1.0=hb9d3cd8_2
  - libbrotlidec=1.1.0=hb9d3cd8_2
  - libbrotlienc=1.1.0=hb9d3cd8_2
  - libcblas=3.9.0=25_linux64_openblas
  - libcurl=8.10.1=hbbe4b11_0
  - libdeflate=1.22=hb9d3cd8_0
  - libedit=3.1.20191231=he28a2e2_2
  - libev=4.33=hd590300_2
  - libexpat=2.6.4=h5888daf_0
  - libffi=3.4.2=h7f98852_5
  - libgcc=14.2.0=h77fa898_1
  - libgcc-ng=14.2.0=h69a702a_1
  - libgfortran=14.2.0=h69a702a_1
  - libgfortran-ng=14.2.0=h69a702a_1
  - libgfortran5=14.2.0=hd5240d6_1
  - libgomp=14.2.0=h77fa898_1
  - libhwloc=2.11.2=default_he43201b_1000
  - libiconv=1.17=hd590300_2
  - libjpeg-turbo=3.0.0=hd590300_1
  - liblapack=3.9.0=25_linux64_openblas
  - libllvm14=14.0.6=hcd5def8_4
  - libnghttp2=1.64.0=h161d5f1_0
  - libnsl=2.0.1=hd590300_0
  - libopenblas=0.3.28=pthreads_h94d23a6_1
  - libpng=1.6.44=hadc24fc_0
  - libsqlite=3.47.0=hadc24fc_1
  - libssh2=1.11.0=h0841786_0
  - libstdcxx=14.2.0=hc0a3c3a_1
  - libstdcxx-ng=14.2.0=h4852527_1
  - libtiff=4.7.0=he137b08_1
  - libuuid=2.38.1=h0b41bf4_0
  - libwebp-base=1.4.0=hd590300_0
  - libxcb=1.17.0=h8a09558_0
  - libxcrypt=4.4.36=hd590300_1
  - libxml2=2.13.4=h064dc61_2
  - libzlib=1.3.1=hb9d3cd8_2
  - llvmlite=0.43.0=py311h9c9ff8c_1
  - matplotlib-base=3.9.2=py311h2b939e6_2
  - mudata=0.3.1=pyhd8ed1ab_0
  - munkres=1.1.4=pyh9f0ad1d_0
  - natsort=8.4.0=pyhd8ed1ab_0
  - ncurses=6.5=he02047a_1
  - networkx=3.4.2=pyhd8ed1ab_1
  - numba=0.60.0=py311h4bc866e_0
  - numpy=2.0.2=py311h71ddf71_0
  - openjpeg=2.5.2=h488ebb8_0
  - openssl=3.3.2=hb9d3cd8_0
  - packaging=24.1=pyhd8ed1ab_0
  - pandas=2.2.2=py311h14de704_1
  - patsy=0.5.6=pyhd8ed1ab_0
  - pillow=11.0.0=py311h49e9ac3_0
  - pip=24.3.1=pyh8b19718_0
  - platformdirs=4.3.6=pyhd8ed1ab_0
  - pooch=1.8.2=pyhd8ed1ab_0
  - pthread-stubs=0.4=hb9d3cd8_1002
  - pycparser=2.22=pyhd8ed1ab_0
  - pynndescent=0.5.13=pyhff2d567_0
  - pyparsing=3.2.0=pyhd8ed1ab_1
  - pysocks=1.7.1=pyha2e5f31_6
  - python=3.11.10=hc5c86c4_3_cpython
  - python-dateutil=2.9.0=pyhd8ed1ab_0
  - python-igraph=0.11.6=py311h9806173_2
  - python-levenshtein=0.26.1=pyhff2d567_0
  - python-tzdata=2024.2=pyhd8ed1ab_0
  - python_abi=3.11=5_cp311
  - pytz=2024.2=pyhd8ed1ab_0
  - pyyaml=6.0.2=py311h9ecbd09_1
  - qhull=2020.2=h434a139_5
  - rapidfuzz=3.10.1=py311hfdbb021_0
  - readline=8.2=h8228510_1
  - requests=2.32.3=pyhd8ed1ab_0
  - scanpy=1.10.3=pyhd8ed1ab_0
  - scikit-learn=1.5.2=py311h57cc02b_1
  - scipy=1.14.1=py311he9a78e4_1
  - scirpy=0.19.0=pyhdfd78af_0
  - seaborn=0.13.2=hd8ed1ab_2
  - seaborn-base=0.13.2=pyhd8ed1ab_2
  - session-info=1.0.0=pyhd8ed1ab_0
  - setuptools=75.3.0=pyhd8ed1ab_0
  - six=1.16.0=pyh6c4a22f_0
  - squarify=0.4.3=py_0
  - statsmodels=0.14.4=py311h9f3472d_0
  - stdlib-list=0.11.0=pyhd8ed1ab_0
  - tbb=2022.0.0=hceb3a55_0
  - texttable=1.7.0=pyhd8ed1ab_0
  - threadpoolctl=3.5.0=pyhc1e730c_0
  - tk=8.6.13=noxft_h4845f30_101
  - tqdm=4.67.0=pyhd8ed1ab_0
  - typing_extensions=4.12.2=pyha770c72_0
  - tzdata=2024b=hc8b5060_0
  - umap-learn=0.5.7=py311h38be061_0
  - unicodedata2=15.1.0=py311h9ecbd09_1
  - urllib3=2.2.3=pyhd8ed1ab_0
  - wheel=0.45.0=pyhd8ed1ab_0
  - xorg-libxau=1.0.11=hb9d3cd8_1
  - xorg-libxdmcp=1.1.5=hb9d3cd8_0
  - xz=5.2.6=h166bdaf_0
  - yaml=0.2.5=h7f98852_2
  - yamlordereddictloader=0.4.0=py_0
  - zipp=3.21.0=pyhd8ed1ab_0
  - zstandard=0.23.0=py311hbc35293_1
  - zstd=1.5.6=ha6fb4c9_0
prefix: /home/nsaw/miniconda3/envs/scirpy

I’m not sure how you ended up there, since you apparently created the conda env from scratch, but I believe there’s still something wrong with your conda env. In particular, the output from conda env export should look differently than what you show above, since most dependencies should be listed in a pip section, while in your output all dependencies appear to be installed by conda directly.

Also in your stacktrace, it seems that not the packages from conda are used, but from your local python library:
/home/nsaw/.local/lib/python3.11/site-packages

I suggest to do the following to clean up:

  1. remove the .local python library. One shouldn’t have it when working with virtual environments:
rm -rf /home/nsaw/.local/lib/python*
  1. Remove the conda env
rm -rf /path/to/conda/env/...
  1. Re-create the conda env as indicated above
conda create -n scirpy python=3.11 -y
conda activate scirpy
  1. Verify you are using pip from within the conda env.
    The following should print a path that points to the bin folder of your conda env.
which pip
  1. pip install scirpy (likely v0.19 includes all the fixes you need, but installing the main branch as you did above also works)

Thank you for the advice even though it wasn’t a scirpy problem! This fix worked.

1 Like