I ran my code using anaconda and it actually opened the browser and just showed “please wait” and said " [TypeError: Protocols cannot be instantiated" . Then I updated my python from 3.9.7 to 3.9.12. And the browser showed “RuntimeError: There is no current event loop in thread ‘ScriptRunner.scriptThread’.”
Steps to reproduce
Code snippet:
#anaconda
2022-10-26 13:22:20.427 INFO numexpr.utils: Note: NumExpr detected 16 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.
2022-10-26 13:22:20.427 INFO numexpr.utils: NumExpr defaulting to 8 threads.
2022-10-26 13:22:21.868
Warning: to view this Streamlit app on a browser, run it with the following
command:
streamlit run D:\Users\admin\anaconda3\envs\py34\lib\site-packages\ipykernel_launcher.py [ARGUMENTS]
RuntimeError: There is no current event loop in thread 'ScriptRunner.scriptThread'.
Traceback:
File "D:\Users\admin\anaconda3\envs\py34\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 562, in _run_script
exec(code, module.__dict__)
File "D:\Users\admin\anaconda3\envs\py34\Lib\site-packages\ipykernel_launcher.py", line 17, in <module>
app.launch_new_instance()
File "D:\Users\admin\anaconda3\envs\py34\lib\site-packages\traitlets\config\application.py", line 845, in launch_instance
app.initialize(argv)
File "D:\Users\admin\anaconda3\envs\py34\lib\site-packages\traitlets\config\application.py", line 88, in inner
return method(app, *args, **kwargs)
File "D:\Users\admin\anaconda3\envs\py34\lib\site-packages\ipykernel\kernelapp.py", line 681, in initialize
self.init_kernel()
File "D:\Users\admin\anaconda3\envs\py34\lib\site-packages\ipykernel\kernelapp.py", line 522, in init_kernel
shell_stream = ZMQStream(self.shell_socket)
File "D:\Users\admin\anaconda3\envs\py34\lib\site-packages\zmq\eventloop\zmqstream.py", line 106, in __init__
self.io_loop = io_loop or IOLoop.current()
File "D:\Users\admin\anaconda3\envs\py34\lib\site-packages\zmq\eventloop\ioloop.py", line 127, in current
loop = ioloop.IOLoop.current(*args, **kwargs)
File "D:\Users\admin\anaconda3\envs\py34\lib\site-packages\tornado\ioloop.py", line 263, in current
loop = asyncio.get_event_loop()
File "D:\Users\admin\anaconda3\envs\py34\lib\asyncio\events.py", line 642, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
What is the file name and contents of the actual app you are trying to launch? The terminal snippet looks like it’s trying to prompt you how to run a streamlit app (streamlit run app_name.py), but it’s filling it in with the ipykernel_launcher.py file buried in the environment files.
Whatever streamlit code you wrote up, if you saved it in a file called app_name.py, then you would want to
Launch your environment terminal
Change directory (cd) to where you have your file saved
Use streamlit run app_name.py to start it up
If that’s what you did, then a little more clarity on what you are trying to run would be helpful.
PS F:\pythonProject> f:
PS F:\pythonProject> cd F:\pythonProject\venv
PS F:\pythonProject\venv> streamlit run Visualization.py
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8501
Network URL: http://192.168.1.7:8501
2022-10-27 09:45:42.988 Uncaught exception
Traceback (most recent call last):
File "F:\Python-3.9.15\lib\site-packages\tornado\http1connection.py", line 276, in _read_message
delegate.finish()
File "F:\Python-3.9.15\lib\site-packages\tornado\routing.py", line 268, in finish
self.delegate.finish()
File "F:\Python-3.9.15\lib\site-packages\tornado\web.py", line 2322, in finish
self.execute()
File "F:\Python-3.9.15\lib\site-packages\tornado\web.py", line 2344, in execute
self.handler = self.handler_class(
File "F:\Python-3.9.15\lib\site-packages\tornado\websocket.py", line 224, in __init__
super().__init__(application, request, **kwargs)
File "F:\Python-3.9.15\lib\site-packages\tornado\web.py", line 215, in __init__
super().__init__()
File "F:\Python-3.9.15\lib\typing.py", line 1083, in _no_init
raise TypeError('Protocols cannot be instantiated')
TypeError: Protocols cannot be instantiated
2022-10-27 09:45:43.009 Uncaught exception
Traceback (most recent call last):
I tried what your suggestion but it didn’t work. I did the same thing on my mac and it worked well.
Do you mean it works on Mac but not on Windows? Or did you mean it didn’t work also. (Just to be sure I’m understanding you here.)
Can you provide the code of the app you are trying to launch? I am seeing your terminal execute the streamlit run command and report back that it launched the app. Did your default browser open? Is there an error message there? If not, can you navigate to localhost:8501 after running streamlit run Visualization.py to see what is displaying. Streamlit reports error messages within the app that can be more helpful than what is displaying in your terminal.