Python 311 scikit-image build error

I am trying to use scikit-image with python 3.11, but I am running into this build error:

==================================== ERRORS ====================================
________ ERROR collecting build/lib.linux-x86_64-cpython-311/module2.py ________
/build/source/pytest_doctestplus/plugin.py:302: in collect
    for test in finder.find(module):
                ^^^^^^^^^^^^^^^^^^^
/build/source/pytest_doctestplus/plugin.py:876: in find
    tests += doctest.DocTestFinder.find(
/nix/store/qfdxhqbb1wrdfzhlyk3m7pq3nb81znr8-python3-3.11.15/lib/python3.11/doctest.py:942: in find
    self._find(tests, obj, name, module, source_lines, globs, {})
/nix/store/qfdxhqbb1wrdfzhlyk3m7pq3nb81znr8-python3-3.11.15/lib/python3.11/doctest.py:1004: in _find
    test = self._get_test(obj, name, module, globs, source_lines)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/nix/store/qfdxhqbb1wrdfzhlyk3m7pq3nb81znr8-python3-3.11.15/lib/python3.11/doctest.py:1072: in _get_test
    lineno = self._find_lineno(obj, source_lines)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/nix/store/qfdxhqbb1wrdfzhlyk3m7pq3nb81znr8-python3-3.11.15/lib/python3.11/doctest.py:1121: in _find_lineno
    obj = inspect.unwrap(obj).__code__
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   AttributeError: 'numpy.ufunc' object has no attribute '__code__'
=========================== short test summary info ============================
ERROR build/lib.linux-x86_64-cpython-311/module2.py - AttributeError: 'numpy....
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 0.41s ===============================
=========================== short test summary info ============================
FAILED tests/test_doctestplus.py::test_ufunc - AssertionError: ([], [], [<CollectReport 'build/lib.linux-x86_64-cpython-31...
============ 1 failed, 45 passed, 7 deselected, 1 xfailed in 7.83s =============
error: Cannot build '/nix/store/k17xmnb5bh0zx18x849r42i4i8hwm6hp-python3.11-pytest-doctestplus-1.4.0.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/7g7s58jzhha1ilgqbfgbcnm81lmsg929-python3.11-pytest-doctestplus-1.4.0
         /nix/store/xgkpd4xdvjphnhw161azmk8cvp4f74i5-python3.11-pytest-doctestplus-1.4.0-dist
       Last 25 log lines:
       > ________ ERROR collecting build/lib.linux-x86_64-cpython-311/module2.py ________
       > /build/source/pytest_doctestplus/plugin.py:302: in collect
       >     for test in finder.find(module):
       >                 ^^^^^^^^^^^^^^^^^^^
       > /build/source/pytest_doctestplus/plugin.py:876: in find
       >     tests += doctest.DocTestFinder.find(
       > /nix/store/qfdxhqbb1wrdfzhlyk3m7pq3nb81znr8-python3-3.11.15/lib/python3.11/doctest.py:942: in find
       >     self._find(tests, obj, name, module, source_lines, globs, {})
       > /nix/store/qfdxhqbb1wrdfzhlyk3m7pq3nb81znr8-python3-3.11.15/lib/python3.11/doctest.py:1004: in _find
       >     test = self._get_test(obj, name, module, globs, source_lines)
       >            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       > /nix/store/qfdxhqbb1wrdfzhlyk3m7pq3nb81znr8-python3-3.11.15/lib/python3.11/doctest.py:1072: in _get_test
       >     lineno = self._find_lineno(obj, source_lines)
       >              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       > /nix/store/qfdxhqbb1wrdfzhlyk3m7pq3nb81znr8-python3-3.11.15/lib/python3.11/doctest.py:1121: in _find_lineno
       >     obj = inspect.unwrap(obj).__code__
       >           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       > E   AttributeError: 'numpy.ufunc' object has no attribute '__code__'
       > =========================== short test summary info ============================
       > ERROR build/lib.linux-x86_64-cpython-311/module2.py - AttributeError: 'numpy....
       > !!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
       > =============================== 1 error in 0.41s ===============================
       > =========================== short test summary info ============================
       > FAILED tests/test_doctestplus.py::test_ufunc - AssertionError: ([], [], [<CollectReport 'build/lib.linux-x86_64-cpython-31...
       > ============ 1 failed, 45 passed, 7 deselected, 1 xfailed in 7.83s =============
       For full logs, run:
         nix-store -l /nix/store/k17xmnb5bh0zx18x849r42i4i8hwm6hp-python3.11-pytest-doctestplus-1.4.0.drv
error: Cannot build '/nix/store/ysz52jn7mkyxfai44zmab2baaydi0dx7-python3.11-astropy-7.1.0.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/g2zzgsxa6rslkcd09rzkzf0z27fr5f9f-python3.11-astropy-7.1.0
         /nix/store/i8qbk997qr2wp6njnj81g9185hj2ipbs-python3.11-astropy-7.1.0-dist
error: Cannot build '/nix/store/zvzpcrid7kmvrqlqshcwqbgh3x5hz0yv-python3.11-imageio-2.37.2.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/7qads3gsvysxll0bwdasm0bf91l9zs6v-python3.11-imageio-2.37.2-dist
         /nix/store/nkk5hqw37fknnig9nwnisv00iazb3lhc-python3.11-imageio-2.37.2
error: Cannot build '/nix/store/7wcy8pkdc1svjaqcsmbar4rhkdmnnawa-python3-3.11.15-env.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/x43gk04wyik40731gfpzaw6ghvamqch2-python3-3.11.15-env

I have this nix-shell to test with:

{ pkgs ? import <nixpkgs> {} }:

let
  blenderPython = pkgs.python311;
  pythonWithPackages = blenderPython.withPackages (ps: [
    ps.scikit-image 
  ]);
in
pkgs.mkShell {
  packages = [
    pythonWithPackages
  ];
}

Python 3.12 works fine, but I’m stuck with python 3.11 because it is the only version supported by blender.

Is there a fix / workaround for this error?

I ended up disabling the test for the dependency that failed and now it is working. Here is the fixed example shell.nix:

{ pkgs ? import <nixpkgs> {} }:

let
  blenderPython = pkgs.python311.override {
    packageOverrides = self: super: {
      pytest-doctestplus = super.pytest-doctestplus.overridePythonAttrs (old: {
        doCheck = false;
      });
    };
  };

  pythonWithPackages = blenderPython.withPackages (ps: [
    ps.scikit-image
  ]);
in
pkgs.mkShell {
  packages = [
    pythonWithPackages
  ];
}