St.write not working with vscode


Running streamlit app in vscode.

Steps to reproduce

Run app using terminal command python -m streamlit run or streamlit run both causes an error
Code snippet:

import streamlit as st
st.write("hello world!")

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

to reproduce the error, run python -m streamlit run or streamlit run

Code snippet
st.write(“hello world!”)
Expected behavior:

Explain what you expect to happen when you run the code above.

I expect to see A browser window should pop-up showing the newly created Streamlit app. This is the day 2 streamlit challenge I am trying to complete

Actual behavior:

Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.


PS C:\Users\cef19> python -m streamlit run
Traceback (most recent call last):
File “C:\ProgramData\Anaconda3\lib\”, line 185, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File “C:\ProgramData\Anaconda3\lib\”, line 144, in _get_module_details
return _get_module_details(pkg_main_name, error)
File “C:\ProgramData\Anaconda3\lib\”, line 111, in get_module_details
File "C:\ProgramData\Anaconda3\lib\site-packages\streamlit_init
.py", line 55, in
from streamlit.delta_generator import DeltaGenerator as DeltaGenerator
File “C:\ProgramData\Anaconda3\lib\site-packages\streamlit\”, line 38, in
from streamlit import config, cursor, env_util, logger, runtime, type_util, util
File “C:\ProgramData\Anaconda3\lib\site-packages\streamlit\”, line 18, in
from streamlit.runtime.scriptrunner import get_script_run_ctx
File "C:\ProgramData\Anaconda3\lib\site-packages\streamlit\runtime_init
.py", line 16, in
from streamlit.runtime.runtime import Runtime as Runtime
File “C:\ProgramData\Anaconda3\lib\site-packages\streamlit\runtime\”, line 26, in
from streamlit.proto.BackMsg_pb2 import BackMsg
File “C:\ProgramData\Anaconda3\lib\site-packages\streamlit\proto\”, line 5, in
from google.protobuf.internal import builder as builder
ImportError: cannot import name ‘builder’ from ‘google.protobuf.internal’ (C:\ProgramData\Anaconda3\lib\site-packages\google\protobuf\internal_init
PS C:\Users\cef19>

Error when run with debugging in vs code
Exception has occurred: AttributeError
partially initialized module ‘streamlit’ has no attribute ‘write’ (most likely due to a circular import)
File “C:\Users\cef19\Desktop\ChrisFranklinStreamLit2\”, line 3, in
st.write(‘hello world!’)
File “C:\Users\cef19\Desktop\ChrisFranklinStreamLit2\”, line 1, in
import streamlit as st

Debug info

  • Streamlit version: (get it with $ streamlit version) Requirement already satisfied: streamlit in c:\programdata\anaconda3\lib\site-packages (1.16.0)

  • Python version: (get it with $ python --version) Python 3.8.5

  • Using Conda? PipEnv? PyEnv? Pex? using Conda

  • OS version: PC

  • Browser version: Chrome

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.

Not sure what a requirements file is? Check out [this doc]
My requirements file.






(App dependencies - Streamlit Docs) and add a requirements file to your app.


Additional information


If needed, add any other context about the problem here.
I will try this with pycharm but vscode should work right?

it is working in pycharm but can you still help me find out why vscode is not working with streamlit. I have pip install streamlit multiple times on vs code so I know its loaded but still not working.
Here is me pip installing streamlit again put it not being recognized in my import streamlit as st. in vscode. I cant believe I am the only one trying to use vscode on windows but not sure. I know alot of people use other os’s. does windows and vscode work with for others?


The screenshot of the error message in the first post indicates there was merely a typo and the ending quotes were missing.

As for VS Code. Make sure you are consistent with which environment you are in.

I created a virtual environment and then created a app in that virtual environment. it does not work in there either. Import streamlit as st does not work so streamlit is not recognized for anything.
I will Send screenshots soon showing my streamlit app created in the virtual environment and the error i get thanks.

I got it to work. created a file in the venv virtual environment You can now view your Streamlit app in your browser.

Local URL: http://localhost:8502
Network URL:

Yep! :+1: You see the (.venv) prefix on your command line to tell you that your terminal is running in that virtual enviroment? That’s the python.exe that’s going to be used when you type streamlit run

If you are still having any issues with your code highlighting text correctly, you can make sure VS Code is using that same environment for interpretation, which was what I circled in the lower right of your first screen shot. (That’s how VS Code knows if a module exists or not and what methods are available to use for it so that you don’t get everything underlined in red squiggles.)