{"id":16021441,"url":"https://github.com/edsaac/stpyvista","last_synced_at":"2025-04-04T15:11:32.048Z","repository":{"id":65357649,"uuid":"531642013","full_name":"edsaac/stpyvista","owner":"edsaac","description":"🧊 Show 3D visualizations from PyVista in Streamlit","archived":false,"fork":false,"pushed_at":"2025-01-30T14:15:53.000Z","size":5423,"stargazers_count":90,"open_issues_count":6,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-03T07:39:17.530Z","etag":null,"topics":["python","pyvista","streamlit","visualization"],"latest_commit_sha":null,"homepage":"https://stpyvista.streamlit.app","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/edsaac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-09-01T18:33:58.000Z","updated_at":"2025-04-01T16:03:50.000Z","dependencies_parsed_at":"2023-12-26T18:38:41.955Z","dependency_job_id":null,"html_url":"https://github.com/edsaac/stpyvista","commit_stats":null,"previous_names":["edsaac/streamlit-pyvista-viewer"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsaac%2Fstpyvista","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsaac%2Fstpyvista/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsaac%2Fstpyvista/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsaac%2Fstpyvista/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edsaac","download_url":"https://codeload.github.com/edsaac/stpyvista/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198468,"owners_count":20900081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python","pyvista","streamlit","visualization"],"created_at":"2024-10-08T18:04:16.686Z","updated_at":"2025-04-04T15:11:32.030Z","avatar_url":"https://github.com/edsaac.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cb\u003e🧊 \u003ccode\u003estpyvista\u003c/code\u003e\u003c/b\u003e\n\u003c/h1\u003e\n\n\u003ch3 align=\"center\"\u003e\n  Show \u003ca href=\"https://docs.pyvista.org/index.html\"\u003ePyVista\u003c/a\u003e visualizations in Streamlit.\n\u003c/h3\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://stpyvista.streamlit.app/\"\u003e\u003cimg alt=\"stpyvista examples and documentation\" src=\"https://img.shields.io/static/v1?label=%20\u0026message=Open%20in%20Community%20Cloud\u0026color=pink\u0026logo=streamlit\" width=200\u003e\u003c/a\u003e \n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/edsaac/stpyvista\"\u003e\u003cimg alt=\"Github Repo\" src=\"https://img.shields.io/static/v1?label=\u0026message=Source code\u0026color=purple\u0026logo=github\"\u003e\u003c/a\u003e \n\u003ca href=\"https://pypi.org/project/stpyvista/\"\u003e\u003cimg alt=\"Check it at PyPI\" src=\"https://badgen.net/pypi/v/stpyvista/\"\u003e\n\u003ca href=\"https://github.com/edsaac/stpyvista-tests\"\u003e\u003cimg alt=\"Github tests repo\" src=\"https://img.shields.io/static/v1?label=\u0026message=Examples\u0026color=purple\u0026logo=github\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n  \n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://stpyvista.streamlit.app\"\u003e\u003cimg alt=\"Streamlit Cloud\" src=\"assets/stpyvista_intro_crop.gif\" width=\"400\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nTake a PyVista plotter object and show it on Streamlit as an interactive\u003cem\u003e-ish\u003c/em\u003e component (as in it can be zoomed in/out, moved and rotated, but the visualization state is not returned). It can use either [Panel](https://panel.holoviz.org/reference/panes/VTK.html#working-with-pyvista) or [Trame](https://docs.pyvista.org/user-guide/jupyter/trame#trame-jupyter) to export the PyVista plotter to HTML; `stpyvista` places it within an iframe in Streamlit.\n\n******\n### 📦 Installation \n\n```sh\npip install stpyvista\n```\n\n******\n\n### 📚 Demo and documentation \n\n\u003ca href=\"https://stpyvista.streamlit.app/\"\u003e\u003cimg alt=\"stpyvista examples and documentation\" src=\"https://img.shields.io/static/v1?label=%20\u0026message=Open%20in%20Community%20Cloud\u0026color=pink\u0026logo=streamlit\" width=200\u003e\u003c/a\u003e \n\n******\n\n### ✨ Minimal example\n\u003cdetails\u003e\n\u003csummary\u003e\n\u003cb\u003eRender a cube\u003c/b\u003e\n\u003c/summary\u003e\n  \n```python\nimport streamlit as st\nimport pyvista as pv\nfrom stpyvista import stpyvista\n\n## Initialize a plotter object\nplotter = pv.Plotter(window_size=[400,400])\n\n## Create a mesh with a cube \nmesh = pv.Cube()\n\n## Add some scalar field associated to the mesh\nmesh['my_scalar'] = mesh.points[:, 2] * mesh.points[:, 0]\n\n## Add mesh to the plotter\nplotter.add_mesh(mesh, scalars='my_scalar', cmap='bwr')\n\n## Final touches\nplotter.view_isometric()\nplotter.add_scalar_bar()\nplotter.background_color = 'white'\n\n## Pass a key to avoid re-rendering at each page change\nstpyvista(plotter, key=\"pv_cube\")\n\n```\n\u003c/details\u003e\n\n****\n\n### 🎈 Deploying to Streamlit Community Cloud\n\n- By default, Community Cloud will run Python 3.12 🎈. Check this on New App → Advanced settings... → Python version.\n- Add `stpyvista` to the `requirements.txt` file.\n- Install `procps`, `libgl1-mesa-glx` and `xvfb` by adding them to the `packages.txt` file.\n- The Community Cloud is a Debian headless machine and Pyvista requires a virtual framebuffer to work. `stpyvista.utils.start_xvfb` checks if Xvfb is running and [starts it](https://docs.pyvista.org/version/stable/api/utilities/_autosummary/pyvista.start_xvfb) if it was not. \n\n  ```python\n  from stpyvista.utils import start_xvfb\n\n  if \"IS_XVFB_RUNNING\" not in st.session_state:\n    start_xvfb()\n    st.session_state.IS_XVFB_RUNNING = True \n  ```\n\n****\n\n### 🚩 Known issues\n- [x] [**`cadquery`**](https://github.com/edsaac/stpyvista/issues/25) conflicts: `cadquery` bundles an outdated version of `vtk`, which ends up conflicting with the `vtk` version that `pyvista` requires. Current solution is to install `stpyvista` **before** cadquery in a virtual environment. For fixing instructions, check [this post on discuss](https://discuss.streamlit.io/t/solved-importerror-vtk-version-conflict-with-cadquery-stpyvista-on-streamlit-cloud/91840).\n- [ ] [`NSInternalInconsistencyException`](https://github.com/edsaac/stpyvista/issues/14) thrown when running on macOS. Current solution is to deploy using a VM.\n\n#### 🍹 Solved issues \n- [x] [`RuntimeError`](https://github.com/edsaac/stpyvista/issues/17) thrown when running Python 3.9. Upgrading to `panel\u003e=1.4.0` or using Python 3.10 fixes this.\n- [x] [Buggy colormaps](https://github.com/edsaac/stpyvista/issues/19) when using `panel==1.4.0`. This [issue](https://github.com/holoviz/panel/issues/6627) was fixed with `panel==1.4.1`.\n- [x] [`cmocean==4.0.1`](https://github.com/matplotlib/cmocean/releases/tag/v4.0.1) will raise an exception while trying to register its colormaps to matplotlib, making PyVista to crash. This [issue](https://github.com/matplotlib/cmocean/issues/107) was fixed in `cmocean==4.0.3`.\n      \n****\n\n### 🍏 Also check\n* The PyVista project at [https://www.pyvista.org/](https://www.pyvista.org/)\n* Working with Panel and Pyvista [https://panel.holoviz.org](https://panel.holoviz.org/reference/panes/VTK.html#working-with-pyvista)\n* @blackary['s blog post](https://blog.streamlit.io/how-to-build-your-own-streamlit-component/) on how to build a custom component\n* Other stuff from me on [https://edsaac.me](https://edsaac.me)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedsaac%2Fstpyvista","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedsaac%2Fstpyvista","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedsaac%2Fstpyvista/lists"}