I want to share a solution to a persistent deployment issue that might help other makers working with CAD visualization. When deploying apps using both cadquery and stpyvista to Streamlit Cloud, you might encounter VTK-related import errors.
This happens because cadquery currently depends on an older VTK version (<=9.2.0), while stpyvista requires VTK >=9.4.0. After days of failed deployments and searching through GitHub issues, I finally found the solution in stpyvista’s known issues.
Working solution:
The key is enforcing the correct dependency order in requirements.txt
:
streamlit
vtk>=9.4.0 # Explicitly enforce newer VTK first
pyvista
stpyvista
cadquery # Let this install its dependencies afterward
numpy
panel
And in packages.txt
:
libgl1-mesa-glx
libglib2.0-0
libxext6
libsm6
libxrender1
xvfb
procps
Important notes:
- The order in requirements.txt is crucial(maybe) - vtk must be declared before cadquery
- Some Linux dependencies are required for 3D rendering
I’ve implemented this in my Lego Brick Generator demo that:
Generates parametric LEGO-compatible models
Exports STEP files
Shows 3D preview with stpyvista
You can see my 7(!) failed deployment attempts in the commit history before getting it right
Hope this helps others struggling with CAD/3D deployments!