How to fix nptyping AttributeError: module 'numpy' has no attribute 'bool8'. Did you mean: 'bool'?

Problem

While running your Python script, you see an error message such as

  File "/home/uli/.local/lib/python3.12/site-packages/cadquery/sketch.py", line 28, in <module>
    from .occ_impl.sketch_solver import (
  File "/home/uli/.local/lib/python3.12/site-packages/cadquery/occ_impl/sketch_solver.py", line 3, in <module>
    from nptyping import NDArray as Array
  File "/home/uli/.local/lib/python3.12/site-packages/nptyping/__init__.py", line 30, in <module>
    from nptyping.ndarray import NDArray
  File "/home/uli/.local/lib/python3.12/site-packages/nptyping/ndarray.py", line 32, in <module>
    from nptyping.shape_expression import (
  File "/home/uli/.local/lib/python3.12/site-packages/nptyping/shape_expression.py", line 35, in <module>
    from nptyping.typing_ import Literal
  File "/home/uli/.local/lib/python3.12/site-packages/nptyping/typing_.py", line 66, in <module>
    Bool8: TypeAlias = np.bool8
                       ^^^^^^^^
  File "/home/uli/.local/lib/python3.12/site-packages/numpy/__init__.py", line 414, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'bool8'. Did you mean: 'bool'?

Solution

Upgrade nptyping

pip install -U nptyping

After that, your script should work as expected.