Streamlit Spaces with "ModuleNotFoundError: No module named 'altair.vegalite.v4'" error
TL;DRIf you encounter the errorModuleNotFoundError: No module named ‘altair.vegalite.v4’in Streamlit Spaces,do one of the following to fix it:Addaltair<5torequirements.txtSet thesdk_versioninREADME.mdto1.20.0or1.21.0.DescriptionAs reported inthis Streamlit forum post, this error started appearing few days ago.This bug occurs when using Streamlit 1.19.0 or earlier with Altair v5, and it became apparent with a recent release of Alteir v5.In Hugging Face Spaces, the default Streamlit version is1.19.0. So creating a new Streamlit Space or rebuilding an existing one will result in this error.To fix it, you can either addaltair<5torequirements.txtor set thesdk_versioninREADME.mdto1.20.0or1.21.0(1.22.0is not yet available on HF Spaces).
2023-06-22T19:01:36Z
This, unfortunately, didn’t work for me. Instead I did the following:[[[How to create a Streamlit desktop app]]]Create the following package.json file to start a new NPM project. Edit the name field.{“name”: “xxx”,“version”: “0.1.0”,“main”: “./build/electron/main.js”,“scripts”: {“dump”: “dump-stlite-desktop-artifacts”,“serve”: “cross-env NODE_ENV=production electron .”,“pack”: “electron-builder --dir”,“dist”: “electron-builder”,“postinstall”: “electron-builder install-app-deps”},“build”: {“files”: [“build/**/*”],“directories”: {“buildResources”: “assets”}},“devDependencies”: {“@stlite/desktop”: “^0.25.0”,“cross-env”: “^7.0.3”,“electron”: “23.1.1”,“electron-builder”: “^23.6.0”}}Here you should change it to the following:->->->->->->->->->->->->->->->->->->->->->->},“devDependencies”: {“@stlite/desktop”: “^0.31.0”,“cross-env”: “^7.0.3”, (check your version, by running npm show cross-env in the command)“electron”: “23.1.1”, (check your version – for me it was 23.1.1)“electron-builder”: “^24.4.0” (depending on the version)}}2.	Run npm update (instead of npm install).3.	Create streamlit_app directory.o	Any directory name can be used here.4.	Create streamlit_app/streamlit_app.py.o	Change the directory name if you used a different name in the previous step.5.	Write your Streamlit app code in streamlit_app/streamlit_app.py.o	The file name streamlit_app.py is not configurable now.6.	Optionally, you can add more contents in the directory, including pages/*.py for multi-page apps, any data files, and so on.7.	Run npm run dump streamlit_app – -r requirements.txt (the requirements file includes like the following:streamlitplotlypandas8.	Run npm run serve (or similar to the video –servewindows)9.	Run npm run dist or yarn dist for packaging.o	This command bundles the ./build directory created in the step above into application files (.app, .exe, .dmg etc.) in the ./dist directory. To customize the built app, e.g. setting the icon, follow the electron-builder instructions.
2023-06-24T07:30:40Z
This forum is about Hugging Face, and this thread is about Streamlit on Hugging Face Spaces,while yours is about@stlite/desktopwhose issues are discussed inits GitHub issuesorits thread in the Streamlit Forum(and the solution has also been postedhere).
2023-06-24T20:10:27Z
thanks@whitphxTo solve the streamlit altair issue add to your  requirements.txtaltair<5here is a functional examplehuggingface.coradames/test-streamlit-altair at mainWe’re on a journey to advance and democratize artificial intelligence through open source and open science.Streamlit – 11 May 23ModuleNotFoundError: No module named 'altair.vegalite.v4'☁️ Streamlit Community CloudaltairThis should fix the issue:   requirements.txt altair<5