cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

pip install is missing vtkmodules for CadQuery 2.6.0

Open mojca opened this issue 3 months ago • 7 comments

I installed pip install --upgrade cadquery in order to get version 2.6.0, but when I try to use it for some models, it no longer works as some dependencies seem to be missing:

  File "D:\Programs\venv\Lib\site-packages\cadquery\occ_impl\shapes.py", line 23, in <module>
    from vtkmodules.vtkCommonDataModel import vtkPolyData
ModuleNotFoundError: No module named 'vtkmodules.vtkCommonDataModel'

I had to manually install cadquery-vtk in order to satisfy the requirement. (This wasn't the case in earlier versions.)

I see that #1786 added some dependencies like trame-vtk to setup.py, just no cadquery-vtk.

mojca avatar Oct 07 '25 06:10 mojca

I have seen that error when VTK did not upgrade properly. You should not have to install cadquery-vtk, manually. ~~it was a package we created to cover Python 3.13 before the official VTK packages supported it.~~ If you install into a fresh environment does it work?

jmwright avatar Oct 07 '25 09:10 jmwright

@mojca What system are you running on? Python and platform?

jmwright avatar Oct 07 '25 09:10 jmwright

Python 3.12.8, Windows 11.

I tried a fresh install now and it seems to work better:

Installing collected packages: typish, typing_extensions, trame-common, six, pyyaml, pyparsing, propcache, pillow, path, packaging, numpy, multimethod, multidict, msgpack, more-itertools, kiwisolver, idna, frozenlist, fonttools, cycler, attrs, aiohappyeyeballs, yarl, trame-client, python-dateutil, nlopt, ezdxf, contourpy, casadi, aiosignal, trame-vtk, matplotlib, aiohttp, wslink, vtk, trame-server, cadquery-ocp, trame, cadquery
Successfully installed aiohappyeyeballs-2.6.1 aiohttp-3.13.0 aiosignal-1.4.0 attrs-25.4.0 cadquery-2.6.0 cadquery-ocp-7.8.1.1.post1 casadi-3.7.2 contourpy-1.3.3 cycler-0.12.1 ezdxf-1.4.2 fonttools-4.60.1 frozenlist-1.8.0 idna-3.10 kiwisolver-1.4.9 matplotlib-3.10.6 more-itertools-10.8.0 msgpack-1.1.1 multidict-6.7.0 multimethod-1.12 nlopt-2.9.1 numpy-2.3.3 packaging-25.0 path-17.1.1 pillow-11.3.0 propcache-0.4.0 pyparsing-3.2.5 python-dateutil-2.9.0.post0 pyyaml-6.0.3 six-1.17.0 trame-3.12.0 trame-client-3.11.1 trame-common-1.0.1 trame-server-3.6.3 trame-vtk-2.10.0 typing_extensions-4.15.0 typish-1.9.3 vtk-9.3.1 wslink-2.4.0 yarl-1.22.0

I'm still getting Segmentation fault at the end, but that's not a regression (it crashes after creating the output files, so it's not blocking me; but that has always been the case).

mojca avatar Oct 07 '25 09:10 mojca

Thanks @mojca

It sounds like there is an issue when upgrading via pip that we need to keep in mind.

I misremembered and thought that 2.3.1 supports Python 3.13 now, but that version got left behind, so cadquery-vtk is indeed installed in Python 3.13 environments. I think newer versions of OCP should support newer versions of VTK, so hopefully we can drop the need for cadquery-vtk eventually.

Do you have an issue open for the segmentation fault you are seeing? Is there a minimal reproducible example that you can share?

jmwright avatar Oct 07 '25 09:10 jmwright

I get the same error as in the start post, but on Fedora Linux 42. To fix the problem, I needed to reinstall VTK with pip install --upgrade vtk==9.3.1 and everything is working again. It seems some package is messing up things, because this is not the first time I encounter this. Not a big deal though as the fix is easy.

Just to mention that this is in an existing virtual environment with Python 3.12

Jopie01 avatar Oct 08 '25 19:10 Jopie01

Thanks @mojca

Do you have an issue open for the segmentation fault you are seeing? Is there a minimal reproducible example that you can share?

Not yet: I didn't know what to report.

The minimal example is import cadquery (but the script needs to finish, it doesn't crash before exiting).

$ python
Python 3.12.8 (tags/v3.12.8:2dc476b, Dec  3 2024, 19:30:04) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cadquery
>>> quit()
Segmentation fault

If I comment out from .assembly import Assembly, Color, Constraint from __init__.py, it no longer crashes. Leaving the first 29 lines of assembly.py is enough for the import to keep crashing, it stops crashing after removing

from .occ_impl.solver import (
    ConstraintKind,
    ConstraintSolver,
    ConstraintSpec as Constraint,
    UnaryConstraintKind,
    BinaryConstraintKind,
)

(I also removed everything below).

mojca avatar Oct 08 '25 20:10 mojca

I opened #1911. But I'm still not sure if there's enough data to be helpful.

mojca avatar Oct 08 '25 20:10 mojca