# Solved ImportError: VTK version conflict with cadquery & stpyvista on Streamlit Cloud

**URL:** <https://discuss.streamlit.io/t/solved-importerror-vtk-version-conflict-with-cadquery-stpyvista-on-streamlit-cloud/91840>\
**Category:** Random\
**Tags:** debugging\
**Created:** [January 30, 2025, 12:01am UTC](https://discuss.streamlit.io/t/solved-importerror-vtk-version-conflict-with-cadquery-stpyvista-on-streamlit-cloud/91840 "2025-01-30T00:01:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![goldengrape](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/goldengrape/32/55464_2.png) [@goldengrape](https://discuss.streamlit.io/u/goldengrape)\
**Post date:** [January 30, 2025, 12:01am UTC](https://discuss.streamlit.io/t/solved-importerror-vtk-version-conflict-with-cadquery-stpyvista-on-streamlit-cloud/91840/1 "2025-01-30T00:01:02Z")

</div>

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](https://github.com/edsaac/stpyvista).

**Working solution:**  
The key is enforcing the correct dependency order in `requirements.txt`:

```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`:

```txt
libgl1-mesa-glx
libglib2.0-0
libxext6
libsm6
libxrender1
xvfb
procps

```

**Important notes:**

1. The order in requirements.txt is crucial(maybe) - vtk must be declared before cadquery
2. Some Linux dependencies are required for 3D rendering

I’ve implemented this in my **[Lego Brick Generator](https://brickgenerator.streamlit.app/)** 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](https://github.com/goldengrape/brick_generator/commits/main) before getting it right 😅

Hope this helps others struggling with CAD/3D deployments!

---

<div class="post-metadata">

**Author:** ![edsaac](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/edsaac/32/47599_2.png) [@edsaac](https://discuss.streamlit.io/u/edsaac)\
**Post date:** [January 30, 2025, 2:14pm UTC](https://discuss.streamlit.io/t/solved-importerror-vtk-version-conflict-with-cadquery-stpyvista-on-streamlit-cloud/91840/2 "2025-01-30T14:14:10Z")

</div>

I’ll link this post in the Readme!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [July 29, 2025, 2:14pm UTC](https://discuss.streamlit.io/t/solved-importerror-vtk-version-conflict-with-cadquery-stpyvista-on-streamlit-cloud/91840/3 "2025-07-29T14:14:22Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
