Pytest error due to Build Fail

After following the developer instructions here, I’ve had trouble getting pytest to work properly. Here is the error:

============================================================== 2 failed, 8661 passed, 28 skipped, 89 xfailed in 452.14s (0:07:32) ================================================================
(skimage-dev) abdullahfatahi@98CJG5J-18B-S scikit-image % pytest skimage
ImportError while loading conftest '/Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/conftest.py'.
skimage/__init__.py:128: in <module>
    _raise_build_error(e)
skimage/__init__.py:103: in _raise_build_error
    raise ImportError(
E   ImportError: cannot import name 'geometry' from 'skimage._shared' (/Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_shared/__init__.py)
E   It seems that scikit-image has not been built correctly.
E
E   Your install of scikit-image appears to be broken.
E   Try re-installing the package following the instructions at:
E   https://scikit-image.org/docs/stable/user_guide/install.html

Everything seems to have built fine as well (shortened log due to character limit):

(skimage-dev) abdullahfatahi@98CJG5J-18B-S scikit-image % spin build -v
$ meson setup build --prefix=/usr
The Meson build system
Version: 1.5.1
Source dir: /Users/abdullahfatahi/PycharmProjects/scikit-image
Build dir: /Users/abdullahfatahi/PycharmProjects/scikit-image/build
Build type: native build
Project name: scikit-image
Project version: 0.24.1rc0.dev0
C compiler for the host machine: cc (clang 14.0.3 "Apple clang version 14.0.3 (clang-1403.0.22.14.1)")
C linker for the host machine: cc ld64 857.1
C++ compiler for the host machine: c++ (clang 14.0.3 "Apple clang version 14.0.3 (clang-1403.0.22.14.1)")
C++ linker for the host machine: c++ ld64 857.1
Cython compiler for the host machine: cython (cython 3.0.11)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wno-unused-function: YES 
Library m found: YES
Checking if "-Wl,--version-script" : links: NO 
Program cython found: YES (/Users/abdullahfatahi/envs/skimage-dev/bin/cython)
Program pythran found: YES (/Users/abdullahfatahi/envs/skimage-dev/bin/pythran)
Program cp found: YES (/bin/cp)
Program python3 found: YES (/Users/abdullahfatahi/envs/skimage-dev/bin/python)
Did not find pkg-config by name 'pkg-config'
Found pkg-config: NO
Run-time dependency python found: YES 3.10
Program _build_utils/cythoner.py found: YES (/Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py)
Compiler for C++ supports arguments -Wno-cpp: YES 
Build targets in project: 59

scikit-image 0.24.1rc0.dev0

  User defined options
    prefix: /usr

Found ninja-1.11.1.git.kitware.jobserver-1 at /Users/abdullahfatahi/envs/skimage-dev/bin/ninja
$ meson compile -v -C build
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /Users/abdullahfatahi/envs/skimage-dev/bin/ninja -C /Users/abdullahfatahi/PycharmProjects/scikit-image/build -v
ninja: Entering directory `/Users/abdullahfatahi/PycharmProjects/scikit-image/build'
[1/171] /Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py ../skimage/_shared/fast_exp.pyx skimage/_shared/fast_exp.cpython-310-darwin.so.p/fast_exp.c
[2/171] /Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py ../skimage/feature/censure_cy.pyx skimage/feature/censure_cy.cpython-310-darwin.so.p/censure_cy.c
[3/171] /Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py ../skimage/draw/_draw.pyx skimage/draw/_draw.cpython-310-darwin.so.p/_draw.c
[4/171] /Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py ../skimage/_shared/geometry.pyx skimage/_shared/geometry.cpython-310-darwin.so.p/geometry.c
[5/171] /Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py ../skimage/_shared/transform.pyx skimage/_shared/transform.cpython-310-darwin.so.p/transform.c
[6/171] /Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py ../skimage/feature/_hoghistogram.pyx skimage/feature/_hoghistogram.cpython-310-darwin.so.p/_hoghistogram.c
[7/171] /Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py ../skimage/feature/_canny_cy.pyx skimage/feature/_canny_cy.cpython-310-darwin.so.p/_canny_cy.c
[8/171] /Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py ../skimage/feature/_sift.pyx skimage/feature/_sift.cpython-310-darwin.so.p/_sift.c
[9/171] /Users/abdullahfatahi/PycharmProjects/scikit-image/skimage/_build_utils/cythoner.py ../skimage/feature/corner_cy.pyx skimage/feature/corner_cy.cpython-310-darwin.so.p/corner_cy.c
.
.
.
$ meson install --only-changed -C build --destdir ../build-install
ninja: Entering directory `/Users/abdullahfatahi/PycharmProjects/scikit-image/build'
ninja: no work to do.
Installing skimage/_shared/transform.cpython-310-darwin.so to /Users/abdullahfatahi/PycharmProjects/scikit-image/build/../build-install/usr/lib/python3.10/site-packages/skimage/_shared
Installing skimage/_shared/fast_exp.cpython-310-darwin.so to /Users/abdullahfatahi/PycharmProjects/scikit-image/build/../build-install/usr/lib/python3.10/site-packages/skimage/_shared
Installing skimage/_shared/geometry.cpython-310-darwin.so to /Users/abdullahfatahi/PycharmProjects/scikit-image/build/../build-install/usr/lib/python3.10/site-packages/skimage/_shared
Installing skimage/_shared/interpolation.cpython-310-darwin.so to /Users/abdullahfatahi/PycharmProjects/scikit-image/build/../build-install/usr/lib/python3.10/site-packages/skimage/_shared
Installing skimage/draw/_draw.cpython-310-darwin.so to /Users/abdullahfatahi/PycharmProjects/scikit-image/build/../build-install/usr/lib/python3.10/site-packages/skimage/draw
.
.
.
Running custom install script '/Users/abdullahfatahi/envs/skimage-dev/bin/python /Users/abdullahfatahi/PycharmProjects/scikit-image/build/meson-private/pycompile.py python-3.10-installed.json 0'
Compiling '/Users/abdullahfatahi/PycharmProjects/scikit-image/build/../build-install/usr/lib/python3.10/site-packages/skimage/__init__.py'...
Compiling '/Users/abdullahfatahi/PycharmProjects/scikit-image/build/../build-install/usr/lib/python3.10/site-packages/skimage/conftest.py'...
Compiling '/Users/abdullahfatahi/PycharmProjects/scikit-image/build/../build-install/usr/lib/python3.10/site-packages/skimage/_shared/__init__.py'...
Compiling '/Users/abdullahfatahi/PycharmProjects/scikit-image/build/../build-install/usr/lib/python3.10/site-packages/skimage/_shared/_dependency_checks.py'...
.
.
.

I’ve redone the procedure to no luck. Apologies if this is an easy fix as I am fairly new to this. Thanks!

No worries @tamimfatahi. There are sometimes still some hiccups with the new meson based approach and I’ve seen pytest fail on meson-compiled setups before. Could you try running these command to see if they pass?

spin build --clean
spin test  # Should be more robust than pytest
spin test -- skimage/  # Alternative

Also note, that our most recent (working) version is usually on our “dev” version of the docs (see the version switcher on the top right of the docs).

You definitely cannot run pytest in the skimage source directory like that. If you build with meson, it installs into build-install, and that needs to be added to path.

Editable install makes that a bit easier, so you could do pip install --no-isolation -e ., and then run pytest, and that should be fine.

But, spin is our recommended avenue of doing these things, so I concurn with Lars’s recommendation.

Let us know if that works!

Thank you both! I did a clean install and followed the dev version instead, now everything seems to be working properly.

1 Like