CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
2.95k stars 276 forks source link

Error when importing cadquery: nptyping.error.InvalidArgumentsError #1046

Closed roipoussiere closed 2 years ago

roipoussiere commented 2 years ago

When trying to import cadquery I get the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File ".../cadquery/cadquery/__init__.py", line 14, in <module>
    from .occ_impl import exporters
  File ".../cadquery/cadquery/occ_impl/exporters/__init__.py", line 10, in <module>
    from ...cq import Workplane
  File ".../cadquery/cadquery/cq.py", line 61, in <module>
    from .sketch import Sketch
  File ".../cadquery/cadquery/sketch.py", line 28, in <module>
    from .occ_impl.sketch_solver import (
  File ".../cadquery/cadquery/occ_impl/sketch_solver.py", line 236, in <module>
    class SketchConstraintSolver(object):
  File ".../cadquery/cadquery/occ_impl/sketch_solver.py", line 265, in SketchConstraintSolver
    self, x0: Array[(Any,), float]
  File ".../cadquery/.venv/lib/python3.9/site-packages/nptyping/ndarray.py", line 73, in __getitem__
    shape_expression, dtype = _get_from_tuple(item)
  File ".../cadquery/.venv/lib/python3.9/site-packages/nptyping/ndarray.py", line 128, in _get_from_tuple
    raise InvalidArgumentsError(
nptyping.error.InvalidArgumentsError: Unexpected argument '(typing.Any,)', expecting Shape[<ShapeExpression>] or Literal[<ShapeExpression>]

I don't use Conda but pip, using the ocpvtk wheel I built yesterday, but someone else got the same error using Conda.

This error is really recent, because there was no problem to install and import cadquery yesterday.

So it's strange, because:

If I use the python cadquery venv I created yesterday I can import cadquery and import typish (without installing it manually). But if I create a new venv (using the same ocpvtk wheel), I get ModuleNotFoundError: No module named 'typish' when trying to import cadquery.

Then if I install typish module and try again, I get the error described above (the suspicious line in the stacktrace is here).

roipoussiere commented 2 years ago

Ok, the issue appears because of the new release of np-typing (2.0) published yesterday.

I can fix the error with pip install 'nptyping<2'.

sethfischer commented 2 years ago

A work-around until this is fixed in master. When following Command Line Installation, specify nptyping 1.4.4.

conda install -c cadquery -c conda-forge cadquery=master nptyping=1.4.4
lorenzncode commented 2 years ago

Is it preferred to make changes to support nptyping v2.0.0?

jmwright commented 2 years ago

@lorenzncode Supporting nptyping 2.x would probably be ideal, but we have to make sure that it doesn't cause problems anywhere else in CQ's dependency tree as well. If it does cause other problems, then we'll have to pin the version to 1.4.4.