Streamlit localhost issue with VS Terminal

I would like to develop a code with Streamlit but I got some problem with Visual Studio Terminal.

Basically Iโ€™m not able to run in on my local host using VS. The error that comes out says when I digit: streamlit run asset_allocation.py is

Traceback (most recent call last):
  File "c:\users\admin\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\admin\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\admin\anaconda3\scripts\streamlit.exe\__main__.py", line 4, in <module>
  File "c:\users\admin\anaconda3\lib\site-packages\streamlit\cli.py", line 27, in <module>
    import streamlit.bootstrap as bootstrap
  File "c:\users\admin\anaconda3\lib\site-packages\streamlit\bootstrap.py", line 29, in <module>
    from streamlit.server.Server import Server
  File "c:\users\admin\anaconda3\lib\site-packages\streamlit\server\Server.py", line 28, in <module>
    import tornado.web
  File "c:\users\admin\anaconda3\lib\site-packages\tornado\web.py", line 87, in <module>
    from tornado.httpserver import HTTPServer
  File "c:\users\admin\anaconda3\lib\site-packages\tornado\httpserver.py", line 29, in <module>

    import ssl
  File "c:\users\admin\anaconda3\lib\ssl.py", line 98, in <module>
    import _ssl             # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.

But if I run the same code on the anaconda prompt it shows me the right address to the localhost.

I would like to have it on the VS terminal because in this way I canโ€™t see the changes real-time.

Hi @Mattia_Bolognesi, welcome to the Streamlit community!

Are you sure that the terminal in VS is pointing to the same Anaconda virtual environment as the Anaconda prompt is?

1 Like

Hi @randyzwitch, thank for your prompt reply!

Yes, I am quite sure that the VS Terminal is pointing to the same Anaconda virtual environment

1 Like

Unfortunately, I donโ€™t have a whole lot else to suggest, as I donโ€™t use Windows that frequently. But when I do have issues with VSCode, itโ€™s usually because I either didnโ€™t activate the same virtual environment in the terminal, or set the interpreter correctly (bottom left of screen)

image

Thank you @randyzwitch, I appreciate it. If you get any news just let me know

A few suggestions:

  • Have you added python to path variable?
  • Have you tried to run Streamlit in a separate command line tool (cmd, git bash, powershell)?

Charly

Hi Charly!

  • Yes, I have
  • I have run it with anaconda prompt and it works.

I would like to have it in the VS terminal so I will be able to see real time changes. Now I am debugging it with anaconda but everytime I want to see changes I have to refresh the local host.

Mattia

1 Like

Iโ€™ll try this myself on Windows today if I can, to at least confirm that it is possible or that I canโ€™t make it work myself :slight_smile:

2 Likes