Still Unable to Execute Streamlit App in VSC

In trying to run an app built with streamlit in Visual Studio Code with the “streamlit run Webby.py” command in the terminal, I get the following error message:

  • FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\KamaKamaKama\OneDrive\VS Code Files> streamlit run Webby.py
streamlit : The term ‘streamlit’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1

  • streamlit run Webby.py
  •   + CategoryInfo          : ObjectNotFound: (streamlit:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

Is there a way around this error so that I can execute my app in Visual Studio Code?

In folder/workspace, VSC Files (standard env for VSC files),

  1. New File
  2. Save As “Webby.py”
  3. Select Recommended Interpreter: C:\Users\KamaKamaKama\AppData\Local\Programs\Python\Python312\python.exe
  4. Save
    5.Open Terminal
  5. In Terminal: pip install streamlit
  6. Save
  7. In editor window: import streamlit as st
  8. Save
  9. [CODE APP]
  10. Save
  11. In terminal: streamlit run Webby.py
  12. ERROR MESSAGE

Do I need to create a venv? At what stage do I do that from VSC? First thing before creating file? I tried that and noticed that terminal shell would not run python, only powershell. If so, how do I ensure streamlit is available for the terminal python shell to run the app when finished?

  • Streamlit version: latest
  • Python version:312
  • Using Conda? PipEnv? PyEnv? Pex?
  • OS version: Windows 11
  • Browser version: Edge

I am brand new to this world. Apologies in advance for my lack of basic understanding. I just want to get over this hurdle/

Hi @KamaKeith

It seems you’re using Python version 3.12 and currently Streamlit supports up to 3.11. Can you try downgrading to 3.11 and see if that works out.

Hope this is helpful!

I will try that! Thank you.

I got it! Not sure why, but after clean install of VSC and Python 3.11, still had same issues. But, when I tried my Desktop as workspace for VSC, error messages disappeared. Smooth as silk.

You can also run streamlit using VS Code Launch and Debug:

  1. Add this code to your launch.json file
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "streamlit",
            "args": ["run", "${file}"]
        }
    ]
}
  1. Make sure the .py file that calls streamlit is the active window
  2. Open Launch and Debug from the VS Code Activity Bar
  3. Run the code by clicking the green arrow at the top of the Launch & Debug sidebar

It should pop a browser window and run the code locally. One of the things I like about this method is re-running doesn’t open additional browsers. It stays contained in a single browser.